nixos-config/flake.nix

73 lines
1.9 KiB
Nix
Raw Normal View History

2021-03-31 22:15:08 +00:00
{
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
2022-10-26 03:39:52 +00:00
inputs.impermanence.url = "github:nix-community/impermanence";
2021-04-06 03:11:17 +00:00
2023-07-07 18:35:13 +00:00
outputs = { self, nixpkgs, impermanence }:
2021-08-20 17:40:05 +00:00
let
2022-12-20 04:55:11 +00:00
inherit (nixpkgs) lib;
2021-11-18 20:45:24 +00:00
mypkgs = pkgs:
2024-05-30 21:18:42 +00:00
self.lib.dirToAttrs ./pkgs (x: pkgs.callPackage x { }) //
2023-06-23 16:50:04 +00:00
{
iso = import lib/gen-iso.nix lib pkgs.system;
2024-05-30 21:18:42 +00:00
};
2022-12-20 04:55:11 +00:00
forAllSystems = lib.genAttrs [ "x86_64-linux" ];
2021-11-18 20:45:24 +00:00
2024-06-17 01:23:59 +00:00
pins = {
nix.registry.nixpkgs.to = {
inherit (nixpkgs) rev;
owner = "NixOS";
repo = "nixpkgs";
type = "github";
};
nix.registry.bck.to = {
owner = "buckley310";
repo = "nixos-config";
type = "github";
};
};
2024-05-18 03:55:35 +00:00
in
{
formatter = forAllSystems (system:
nixpkgs.legacyPackages.${system}.nixpkgs-fmt);
lib = {
2024-08-15 23:12:56 +00:00
base64 = import lib/base64.nix;
2024-05-18 03:55:35 +00:00
gen-ssh-config = import lib/gen-ssh-config.nix lib;
ssh-keys = import lib/ssh-keys.nix;
2024-05-30 21:18:42 +00:00
dirToAttrs = dir: f: lib.mapAttrs'
(name: _: {
name = lib.removeSuffix ".nix" name;
value = f "${toString dir}/${name}";
})
(builtins.readDir dir);
2024-05-18 03:55:35 +00:00
};
nixosModules =
2022-06-15 02:52:14 +00:00
{
2024-06-17 01:23:59 +00:00
inherit pins;
2022-10-26 03:39:52 +00:00
inherit (impermanence.nixosModules) impermanence;
2022-06-15 02:52:14 +00:00
pkgs.nixpkgs.overlays = [ (_: mypkgs) ];
} //
2024-05-30 21:18:42 +00:00
self.lib.dirToAttrs ./modules import;
2021-06-12 01:32:23 +00:00
2024-05-30 21:18:42 +00:00
nixosConfigurations = self.lib.dirToAttrs ./hosts
(dir:
let cfg = import dir;
2024-05-29 04:51:09 +00:00
in lib.nixosSystem {
inherit (cfg) system;
modules =
cfg.modules ++
2024-05-30 21:18:42 +00:00
[{ networking.hostName = builtins.baseNameOf dir; }] ++
2024-05-29 04:51:09 +00:00
(builtins.attrValues self.nixosModules);
}
);
2021-06-05 06:22:38 +00:00
2022-05-04 17:34:39 +00:00
packages = forAllSystems (system:
mypkgs nixpkgs.legacyPackages.${system});
};
2021-03-31 22:15:08 +00:00
}