puter/flake.nix

131 lines
3.1 KiB
Nix
Raw Permalink Normal View History

2023-09-17 11:31:20 +00:00
{
description = "My NixOS configuration";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
hardware.url = "github:NixOS/nixos-hardware";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
impermanence.url = "github:nix-community/impermanence";
sops-nix.url = "github:Mic92/sops-nix";
};
outputs = {
self,
nixpkgs,
home-manager,
2023-09-29 18:39:08 +00:00
impermanence,
2023-09-17 11:31:20 +00:00
sops-nix,
...
} @ inputs: let
inherit (self) outputs;
forEachSystem = f:
nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
] (system:
f {
pkgs = import nixpkgs {inherit system;};
});
2023-09-29 18:39:08 +00:00
mkSystem = name: {
class,
modules ? [],
...
}:
2023-09-17 11:31:20 +00:00
nixpkgs.lib.nixosSystem ({
specialArgs = {inherit inputs;};
}
// {
modules =
modules
++ [
({
lib,
config,
...
}: {
nix = {
registry = lib.mapAttrs (_: value: {flake = value;}) inputs;
2023-09-29 18:39:08 +00:00
nixPath = lib.mapAttrsToList (key: _: "${key}=flake:${key}") config.nix.registry;
2023-09-17 11:31:20 +00:00
settings = {
experimental-features = "nix-command flakes";
auto-optimise-store = true;
};
};
nixpkgs.config.allowUnfree = true;
networking.hostName = lib.mkDefault name;
})
2023-09-29 18:39:08 +00:00
(./system + "/${name}")
({lib, ...}: {
2023-09-17 11:31:20 +00:00
home-manager = {
useGlobalPkgs = true;
extraSpecialArgs = {inherit inputs;};
2023-09-29 18:39:08 +00:00
users = lib.mapAttrs (username: user:
user
// {
imports =
user.imports
++ [
({config, ...}: {
home = {
username = lib.mkDefault username;
homeDirectory = lib.mkDefault "/home/${config.home.username}";
};
systemd.user.startServices = "sd-switch";
})
(./common/user + "/${class}.nix")
];
2023-09-17 11:31:20 +00:00
})
2023-09-29 18:39:08 +00:00
(import (./user + "/${name}"));
2023-09-17 11:31:20 +00:00
};
2023-09-29 18:39:08 +00:00
})
(./common/system + "/${class}.nix")
home-manager.nixosModules.home-manager
2023-10-08 10:23:00 +00:00
(impermanence + "/nixos.nix")
2023-09-17 11:31:20 +00:00
(sops-nix + "/modules/sops")
];
});
2023-09-29 18:39:08 +00:00
systems = {
glacier = {
class = "desktop";
};
2023-09-17 11:31:20 +00:00
2023-09-29 18:39:08 +00:00
flamingo = {
class = "desktop";
};
2023-09-17 11:31:20 +00:00
2023-09-29 18:39:08 +00:00
scenery = {
class = "desktop";
2023-09-17 11:31:20 +00:00
};
2023-09-29 18:39:08 +00:00
abacus = {
class = "server";
};
2023-09-17 11:31:20 +00:00
2023-09-29 18:39:08 +00:00
vessel = {
class = "server";
2023-09-17 11:31:20 +00:00
};
};
in {
formatter = forEachSystem ({pkgs}: pkgs.alejandra);
2023-09-29 18:39:08 +00:00
nixosConfigurations = nixpkgs.lib.mapAttrs mkSystem systems;
2023-09-17 11:31:20 +00:00
};
}