nixos/flake.nix
Evie Litherland-Smith 78f7af88a8 Move autoUpgrade back to flake.nix but use flake output instead of URL
Set autoUpgrade flake to current flake outpath but keeping nixpkgs
update, means things won't automatically be rolled back if there's no
internet connection. Keep using remote URL for server though to keep
unattended updates.
2024-02-26 08:12:26 +00:00

242 lines
7.1 KiB
Nix

{
description = "Evie's machine configurations";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
stylix = {
url = "github:danth/stylix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
nixpkgs,
home-manager,
stylix,
...
}: let
systemConfig = {
hostName ? "Atlas",
user ? "xenia",
system ? "x86_64-linux",
stateVersion ? "23.05",
systemModules ? [],
homeModules ? [],
}: let
shell = "zsh";
specialArgs = {
inherit hostName user;
accentColour = "base0E"; # magenta
};
in
nixpkgs.lib.nixosSystem {
inherit system specialArgs;
modules =
[
home-manager.nixosModules.home-manager
stylix.nixosModules.stylix
./hosts/${hostName}/configuration.nix
./hosts/${hostName}/hardware-configuration.nix
./system/default.nix
({
lib,
pkgs,
...
}: {
nix = {
enable = true;
settings = {
trusted-users = ["root" user];
experimental-features = ["nix-command" "flakes"];
auto-optimise-store = true;
};
channel.enable = true;
nixPath = ["nixpkgs=${pkgs.path}"];
registry.nixpkgs.flake = nixpkgs;
gc = {
automatic = true;
options = "--delete-older-than 7d";
};
optimise.automatic = true;
extraOptions = ''
keep-outputs = false
keep-derivations = false
min-free = ${toString (100 * 1024 * 1024)}
max-free = ${toString (1024 * 1024 * 1024)}
'';
};
nixpkgs.config.allowUnfree = true;
networking = {inherit hostName;};
programs.${shell}.enable = true;
system = {
inherit stateVersion;
autoUpgrade = {
enable = true;
flake = lib.mkDefault self.outPath;
flags = [
"--update-input"
"nixpkgs"
"--no-write-lock-file"
"-L" # print build logs
];
dates = "02:00";
};
};
users = {
defaultUserShell = pkgs.${shell};
users = let
authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINI1dWlS16Keil0MGPWmMsBzx8F9ylfz+fRwxUr8/tZ/ ion"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDOcgeR3hh23aTiXnyC37xdP8oXfTZbbjgWzkUyxhT9P root@Vanguard"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIANfkqd5lPTsSPU3SRYnAa1UjCYDmDeBTyzq5McmWlm6 xenia@Vanguard"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ/ZSSCN5sqrA+tdoIZr5EUm5DRuBV4dQ7J+QBEtUwUU xenia@Northstar"
];
in {
root.openssh = {inherit authorizedKeys;};
${user} = {
group = "users";
isNormalUser = true;
description = "Evie Litherland-Smith";
extraGroups = ["networkmanager" "wheel" "video" "input" "uinput"];
initialHashedPassword = "$y$j9T$tHIPQt09Kf3KH2eIRze3g/$2mwSlcq27DTGvHNPJ5EP9/1CfL3bXP0F6oS/Vuffmn3";
openssh = {inherit authorizedKeys;};
};
};
};
home-manager = {
extraSpecialArgs = specialArgs;
useGlobalPkgs = true;
useUserPackages = true;
users = {
root = {
imports = [./home/default.nix];
home = {
inherit stateVersion;
username = "root";
homeDirectory = "/root";
};
programs.home-manager.enable = true;
};
${user} = let
username = user;
homeDirectory = "/home/${user}";
in {
imports =
[./hosts/${hostName}/home.nix ./home/default.nix]
++ homeModules;
home = {inherit username homeDirectory stateVersion;};
programs.home-manager.enable = true;
xdg.userDirs = {
enable = true;
createDirectories = true;
extraConfig = {
XDG_PROJECTS_DIR = "${homeDirectory}/Projects";
};
};
};
};
};
})
]
++ systemModules;
};
in {
nixosConfigurations = {
## Server
Legion = let
hostName = "Legion";
user = "xenia";
system = "x86_64-linux";
in
systemConfig {
inherit hostName user system;
systemModules = [
./services/caddy.nix
./services/gitea.nix
./services/grafana.nix
./services/minecraft.nix
./services/sshd.nix
./services/syncthing.nix
];
homeModules = [
./home/default.nix
];
};
## Personal
Northstar = let
hostName = "Northstar";
user = "xenia";
system = "x86_64-linux";
in
systemConfig {
inherit hostName user system;
systemModules = [
./system/laptop.nix
./system/hyprland.nix
./system/games.nix
];
homeModules = [
./home/hyprland/default.nix
];
};
Vanguard = let
hostName = "Vanguard";
user = "xenia";
system = "x86_64-linux";
in
systemConfig {
inherit hostName user system;
systemModules = [
./system/hyprland.nix
./system/games.nix
];
homeModules = [
./home/hyprland/default.nix
];
};
## Work
Ronin = let
hostName = "Ronin";
user = "elitherl";
system = "x86_64-linux";
in
systemConfig {
inherit hostName user system;
systemModules = [
./system/laptop.nix
./system/hyprland.nix
];
homeModules = [
./home/hyprland/default.nix
];
};
Scorch = let
hostName = "Scorch";
user = "elitherl";
system = "x86_64-linux";
in
systemConfig {
inherit hostName user system;
systemModules = [
./system/hyprland.nix
];
homeModules = [
./home/hyprland/default.nix
];
};
};
};
}