diff --git a/README.md b/README.md index 81bbe1f..35cb589 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ The canonical location for this repository is https://git.qenya.tel/qenya/nixfil ### Building -To build locally, run `colmena apply-local` as root. +To build locally, run `nixos-rebuild switch --flake .#[hostname]` as root. To build the remote machines, run `colmena apply`. See the [colmena documentation](https://colmena.cli.rs/) for command-line options. Notable options include: * `--on [hostname]`: build a specific machine only diff --git a/common/default.nix b/common/default.nix index fd0791c..a1f43a4 100644 --- a/common/default.nix +++ b/common/default.nix @@ -6,6 +6,7 @@ ./environment.nix ./home-manager.nix ./nginx.nix + ./nix.nix ./openssh.nix ./security.nix ./steam.nix diff --git a/common/nix.nix b/common/nix.nix new file mode 100644 index 0000000..9361188 --- /dev/null +++ b/common/nix.nix @@ -0,0 +1,7 @@ +{ config, lib, pkgs, ... }: + +{ + nix.settings.experimental-features = "nix-command flakes"; + nix.nixPath = [ "nixpkgs=flake:nixpkgs" ]; + nixpkgs.config.allowUnfree = true; +} diff --git a/common/users/qenya.nix b/common/users/qenya.nix index e9d11ad..6e96e58 100644 --- a/common/users/qenya.nix +++ b/common/users/qenya.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, lib, pkgs, inputs, ... }: let keys = import ../../keys.nix; in { @@ -11,4 +11,6 @@ in { }; programs.zsh.enable = true; + + home-manager.users."qenya" = inputs.self.homeManagerModules."qenya"; } diff --git a/flake.lock b/flake.lock index 3ecf0fb..c0faff0 100644 --- a/flake.lock +++ b/flake.lock @@ -39,6 +39,60 @@ "url": "https://git.qenya.tel/qenya/birdsong" } }, + "colmena": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ], + "stable": "stable" + }, + "locked": { + "lastModified": 1711386353, + "narHash": "sha256-gWEpb8Hybnoqb4O4tmpohGZk6+aerAbJpywKcFIiMlg=", + "owner": "zhaofengli", + "repo": "colmena", + "rev": "cd65ef7a25cdc75052fbd04b120aeb066c3881db", + "type": "github" + }, + "original": { + "owner": "zhaofengli", + "repo": "colmena", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1650374568, + "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -67,11 +121,11 @@ ] }, "locked": { - "lastModified": 1720042825, - "narHash": "sha256-A0vrUB6x82/jvf17qPCpxaM+ulJnD8YZwH9Ci0BsAzE=", + "lastModified": 1726592409, + "narHash": "sha256-2Y6CDvD/BD43WLS77PHu6dUHbdUfFhuzkY8oJAecD/U=", "owner": "nix-community", "repo": "home-manager", - "rev": "e1391fb22e18a36f57e6999c7a9f966dc80ac073", + "rev": "2ab00f89dd3ecf8012f5090e6d7ca1a7ea30f594", "type": "github" }, "original": { @@ -83,11 +137,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1725001927, - "narHash": "sha256-eV+63gK0Mp7ygCR0Oy4yIYSNcum2VQwnZamHxYTNi+M=", + "lastModified": 1726447378, + "narHash": "sha256-2yV8nmYE1p9lfmLHhOCbYwQC/W8WYfGQABoGzJOb1JQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6e99f2a27d600612004fbd2c3282d614bfee6421", + "rev": "086b448a5d54fd117f4dc2dee55c9f0ff461bdc1", "type": "github" }, "original": { @@ -97,13 +151,29 @@ "type": "github" } }, + "nixpkgsSmall": { + "locked": { + "lastModified": 1726611721, + "narHash": "sha256-oSDOQ5c7CTVzkaG5A19UW3Yxsv9TLNFNcrvQT9F4Pz0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a51a2cef87fc37c7e31d3a5345bc493e5f7a5f6e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05-small", + "repo": "nixpkgs", + "type": "github" + } + }, "nur": { "locked": { - "lastModified": 1725486293, - "narHash": "sha256-XRWbx8JcTCVoGxr3P2YL/tK4s4HzZBhUqlxr91zLOZs=", + "lastModified": 1726681508, + "narHash": "sha256-xz858EXcKZjWR6TPyU84BTeMHIPewGW68DutnxghaR4=", "owner": "nix-community", "repo": "NUR", - "rev": "444e1f3fdf23aa476489b0038e0738c6f4d9df85", + "rev": "59c5c2575c0cae6bc98b9de8161731cfb8cdc1f0", "type": "github" }, "original": { @@ -122,11 +192,11 @@ ] }, "locked": { - "lastModified": 1725914634, - "narHash": "sha256-U74hu15xSb6JNySMOwyJrsh4uk1DVa182bdHLeHdYMc=", + "lastModified": 1726509788, + "narHash": "sha256-PmCmO8NDKzwHrTp9Ox/rcLiCYivqIpZlnLk8wZRjv2I=", "owner": "nix-community", "repo": "plasma-manager", - "rev": "60becd0e994e25b372c8d0500fc944396f6c1085", + "rev": "5a0c70a007837e2db01e0bb68971792e8653d32c", "type": "github" }, "original": { @@ -139,12 +209,30 @@ "inputs": { "agenix": "agenix", "birdsong": "birdsong", + "colmena": "colmena", "home-manager": "home-manager_2", "nixpkgs": "nixpkgs", + "nixpkgsSmall": "nixpkgsSmall", "nur": "nur", "plasma-manager": "plasma-manager" } }, + "stable": { + "locked": { + "lastModified": 1696039360, + "narHash": "sha256-g7nIUV4uq1TOVeVIDEZLb005suTWCUjSY0zYOlSBsyE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "32dcb45f66c0487e92db8303a798ebc548cadedc", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, diff --git a/flake.nix b/flake.nix index 71aa94d..50a5c8a 100644 --- a/flake.nix +++ b/flake.nix @@ -2,6 +2,8 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; + nixpkgsSmall.url = "github:NixOS/nixpkgs/nixos-24.05-small"; + home-manager = { url = "github:nix-community/home-manager/release-24.05"; inputs.nixpkgs.follows = "nixpkgs"; @@ -23,39 +25,16 @@ }; }; + colmena = { + url = "github:zhaofengli/colmena"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + birdsong.url = "git+https://git.qenya.tel/qenya/birdsong?ref=main"; }; - outputs = inputs@{ self, nixpkgs, home-manager, plasma-manager, nur, agenix, birdsong, ... }: { - nixosModules.default = { - nix.settings.experimental-features = "nix-command flakes"; - nix.nixPath = [ "nixpkgs=flake:nixpkgs" ]; - nixpkgs.config.allowUnfree = true; - - nixpkgs.overlays = [ nur.overlay ]; - - # TODO: make this or something like it work without infinite recursion - # home-manager.users."qenya" = lib.mkIf (config.users.users ? "qenya") self.homeManagerModules."qenya"; - home-manager.users."qenya" = self.homeManagerModules."qenya"; - - imports = [ - home-manager.nixosModules.home-manager - nur.nixosModules.nur - agenix.nixosModules.default - birdsong.nixosModules.default - ./common - ./services - ]; - }; - - # TODO: simplify - nixosConfigurations = { - "kilgharrah" = nixpkgs.lib.nixosSystem { modules = [ ./hosts/kilgharrah self.nixosModules.default ]; }; - "tohru" = nixpkgs.lib.nixosSystem { modules = [ ./hosts/tohru self.nixosModules.default ]; }; - "yevaud" = nixpkgs.lib.nixosSystem { modules = [ ./hosts/yevaud self.nixosModules.default ]; }; - "orm" = nixpkgs.lib.nixosSystem { modules = [ ./hosts/orm self.nixosModules.default ]; }; - "kalessin" = nixpkgs.lib.nixosSystem { modules = [ ./hosts/kalessin self.nixosModules.default ]; }; - }; + outputs = inputs@{ self, nixpkgs, nixpkgsSmall, home-manager, plasma-manager, nur, agenix, colmena, birdsong, ... }: { + nixosConfigurations = (colmena.lib.makeHive self.outputs.colmena).nodes; # The name of this output type is not standardised. I have picked # "homeManagerModules" as the discussion here suggests it's the most common: @@ -75,11 +54,26 @@ colmena = { meta = { nixpkgs = import nixpkgs { system = "x86_64-linux"; }; - nodeNixpkgs = builtins.mapAttrs (name: value: value.pkgs) self.nixosConfigurations; + nodeNixpkgs = { + kilgharrah = import nixpkgs { system = "x86_64-linux"; }; + tohru = import nixpkgs { system = "x86_64-linux"; }; + yevaud = import nixpkgsSmall { system = "x86_64-linux"; }; + orm = import nixpkgsSmall { system = "x86_64-linux"; }; + kalessin = import nixpkgsSmall { system = "aarch64-linux"; }; + }; + specialArgs = { inherit inputs; }; }; - # TODO: eliminate duplication with nixosConfigurations - defaults.imports = [ self.nixosModules.default ]; + defaults.imports = [ + home-manager.nixosModules.home-manager + nur.nixosModules.nur + { nixpkgs.overlays = [ nur.overlay ]; } + agenix.nixosModules.default + birdsong.nixosModules.default + ./common + ./services + ]; + kilgharrah.imports = [ ./hosts/kilgharrah ]; tohru.imports = [ ./hosts/tohru ]; yevaud.imports = [ ./hosts/yevaud ]; diff --git a/home/qenya/vscode.nix b/home/qenya/vscode.nix index f9d8c6e..5a4c9bd 100644 --- a/home/qenya/vscode.nix +++ b/home/qenya/vscode.nix @@ -38,10 +38,7 @@ in "nix.serverSettings".nil = { diagnostics.ignored = [ "unused_binding" "unused_with" ]; formatting.command = [ "nixpkgs-fmt" ]; - nix.flake = { - autoArchive = true; - autoEvalInputs = true; - }; + nix.flake.autoArchive = true; }; "terminal.integrated.allowChords" = false; "terminal.integrated.defaultProfile.linux" = "zsh";