flake: Use flake-parts to define devShells cross-system

This commit is contained in:
Katherina Walshe-Grey 2025-02-26 20:29:46 +00:00
parent 17402985b6
commit a700ee2445
2 changed files with 108 additions and 74 deletions

View file

@ -108,6 +108,24 @@
"type": "gitlab" "type": "gitlab"
} }
}, },
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1738453229,
"narHash": "sha256-7H9XgNiGLKN1G1CgRh0vUL4AheZSYzPm+zmZ7vxbJdo=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "32ea77a06711b758da0ad9bd6a844c5740a87abd",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-utils": { "flake-utils": {
"locked": { "locked": {
"lastModified": 1659877975, "lastModified": 1659877975,
@ -266,6 +284,18 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs-lib": {
"locked": {
"lastModified": 1738452942,
"narHash": "sha256-vJzFZGaCpnmo7I6i416HaBLpC+hvcURh/BQwROcGIp8=",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/072a6db25e947df2f31aab9eccd0ab75d5b2da11.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/072a6db25e947df2f31aab9eccd0ab75d5b2da11.tar.gz"
}
},
"nixpkgs-small": { "nixpkgs-small": {
"locked": { "locked": {
"lastModified": 1740430871, "lastModified": 1740430871,
@ -360,6 +390,7 @@
"birdsong": "birdsong", "birdsong": "birdsong",
"colmena": "colmena", "colmena": "colmena",
"firefox-addons": "firefox-addons", "firefox-addons": "firefox-addons",
"flake-parts": "flake-parts",
"home-manager": "home-manager", "home-manager": "home-manager",
"home-manager-unstable": "home-manager-unstable", "home-manager-unstable": "home-manager-unstable",
"lix-module": "lix-module", "lix-module": "lix-module",

View file

@ -26,6 +26,8 @@
inputs.home-manager.follows = "home-manager-unstable"; inputs.home-manager.follows = "home-manager-unstable";
}; };
flake-parts.url = "github:hercules-ci/flake-parts";
agenix = { agenix = {
url = "github:ryantm/agenix"; url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
@ -66,9 +68,24 @@
}; };
}; };
outputs = inputs@{ self, nixpkgs, nixpkgs-small, nixpkgs-unstable, colmena, ... }: { outputs = inputs@{ self, nixpkgs, nixpkgs-small, nixpkgs-unstable, flake-parts, colmena, ... }:
nixosConfigurations = self.outputs.colmenaHive.nodes; flake-parts.lib.mkFlake { inherit inputs; } {
colmenaHive = colmena.lib.makeHive self.outputs.colmena; imports = [ ];
systems = [ "x86_64-linux" "aarch64-linux" ];
perSystem = { pkgs, system, ... }: {
devShells.default = pkgs.mkShell {
packages = [
inputs.colmena.packages.${system}.colmena
inputs.agenix.packages.${system}.default
inputs.plasma-manager.packages.${system}.rc2nix
];
};
};
flake.nixosConfigurations = self.outputs.colmenaHive.nodes;
flake.colmenaHive = colmena.lib.makeHive self.outputs.colmena;
# The name of this output type is not standardised. I have picked # The name of this output type is not standardised. I have picked
# "homeManagerModules" as the discussion here suggests it's the most common: # "homeManagerModules" as the discussion here suggests it's the most common:
@ -76,7 +93,7 @@
# #
# However, note CppNix >= 2.22.3, >= 2.24 has blessed "homeModules": # However, note CppNix >= 2.22.3, >= 2.24 has blessed "homeModules":
# https://github.com/NixOS/nix/pull/10858 # https://github.com/NixOS/nix/pull/10858
homeManagerModules = { flake.homeManagerModules = {
"qenya".imports = [ "qenya".imports = [
inputs.plasma-manager.homeManagerModules.plasma-manager inputs.plasma-manager.homeManagerModules.plasma-manager
./home/qenya ./home/qenya
@ -85,7 +102,7 @@
"qenya@shaw".imports = [ ./hosts/shaw/home.nix ]; "qenya@shaw".imports = [ ./hosts/shaw/home.nix ];
}; };
colmena = { flake.colmena = {
meta = { meta = {
nixpkgs = import nixpkgs-unstable { nixpkgs = import nixpkgs-unstable {
system = "x86_64-linux"; system = "x86_64-linux";
@ -137,19 +154,5 @@
orm.imports = [ ./hosts/orm ]; orm.imports = [ ./hosts/orm ];
kalessin.imports = [ ./hosts/kalessin ]; kalessin.imports = [ ./hosts/kalessin ];
}; };
# TODO: have this work on other systems too
devShells."x86_64-linux".default =
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
in
pkgs.mkShell {
packages = [
inputs.colmena.packages.${system}.colmena
inputs.agenix.packages.${system}.default
inputs.plasma-manager.packages.${system}.rc2nix
];
};
}; };
} }