NixOSConfig/flake.nix

84 lines
2.2 KiB
Nix

{
description = "NixOS Machine Configurations by manuth";
inputs = {
nixpkgs.url = "nixpkgs/38c01297e7ec11f7b9e3f2cae7d6fcec6cc767ec";
flake-utils.url = "github:numtide/flake-utils?ref=b1d9ab70662946ef0850d488da1c9019f3a9752a";
sops-nix.url = "github:Mic92/sops-nix?ref=f1b0adc27265274e3b0c9b872a8f476a098679bd";
};
outputs = { self, nixpkgs, flake-utils, sops-nix }: (
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
config = {};
overlays = [
sops-nix.overlays.default
];
};
in {
devShells.default = pkgs.mkShellNoCC (
with pkgs;
{
sopsPGPKeyDirs = [
"${toString ./.}/keys/hosts"
"${toString ./.}/keys/users"
];
packages = [
nixos-rebuild
sops
sops-import-keys-hook
ssh-to-age
ssh-to-pgp
];
nativeBuildInputs = [
sops-import-keys-hook
];
});
}
) // {
nixosConfigurations =
let
systems = [
{
name = "nixos";
}
];
in
builtins.listToAttrs (
builtins.map (
{ name, system ? "x86_64-linux", ... }@config: {
inherit name;
value = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
({ ... }: { config._module.args = { machineConfig = config; }; })
sops-nix.nixosModules.sops
./lib/configuration.nix
(
let
configCandidate = ./lib/machines/${name}.nix;
machineConfigPath =
if builtins.pathExists configCandidate
then
configCandidate
else
./lib/hardware/base.nix;
in
machineConfigPath)
];
};
})
systems);
});
}