NixOSConfig/flake.nix

95 lines
2.5 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 }: (
let
inherit (nixpkgs) lib;
tryFiles = files: default:
lib.lists.foldr
(a: b:
if builtins.pathExists a
then a
else b)
default
files;
in
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
default = { pkgs, ... }: {
dualBoot = false;
timeZone = null;
keyMap = "us";
keyboardLayout = "us";
localeSettings = { };
users = { };
};
systems = {
nixos.config = { ... }: {
};
};
in
builtins.mapAttrs (
name: { system ? "x86_64-linux", config }: nixpkgs.lib.nixosSystem {
inherit system;
modules = [
(
{ pkgs, ... }@args: {
config._module.args = {
hostname = name;
machineConfig = (default args) //
(config args) // {
inherit name;
};
};
})
sops-nix.nixosModules.sops
./lib/configuration.nix
(tryFiles [ ./lib/machines/${name}.nix ] ./lib/hardware/base.nix)
];
})
systems;
});
}