systems/flake.nix

143 lines
4.3 KiB
Nix

{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-25.11";
nix-darwin.url = "github:nix-darwin/nix-darwin?ref=nix-darwin-25.11";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
home-manager.url = "github:nix-community/home-manager?ref=release-25.11";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
lanzaboote.url = "github:nix-community/lanzaboote?ref=master";
lanzaboote.inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
{ self, nixpkgs, ... }@inputs:
let
supportedSystems = [
"x86_64-linux"
"aarch64-darwin"
];
lib = import ./lib { inherit (inputs.nixpkgs) lib; };
pkgsFor =
system:
import inputs.nixpkgs {
inherit system;
config.allowUnfree = true;
};
forEachSupportedSystem =
f:
inputs.nixpkgs.lib.genAttrs supportedSystems (
system:
f {
inherit system;
pkgs = pkgsFor system;
}
);
in
{
nixosConfigurations."persephone" = nixpkgs.lib.nixosSystem {
modules = [
inputs.lanzaboote.nixosModules.lanzaboote
inputs.home-manager.nixosModules.home-manager
(
{ config, lib, ... }:
{
imports = [
(lib.mkAliasOptionModule [ "hm" ] [ "home-manager" "users" "${config.machine.mainUser}" ])
];
}
)
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
hm.programs.bat.enable = true;
hm.home.stateVersion = "25.11";
}
./machines/persephone.nix
(
{ lib, ... }:
{
options.machine = {
fs = {
bootUUID = lib.mkOption {
type = lib.types.str;
description = "The UUID of the XBOOTLDR partition.";
default = "9c2d7380-571d-4bc5-9ad2-e4888ce351be";
};
efiUUID = lib.mkOption {
type = lib.types.str;
description = "The UUID of the ESP.";
default = "71E7-7A63";
};
luuksUUID = lib.mkOption {
type = lib.types.str;
description = "The UUID of the encrypted root partition.";
default = "b0ace3a0-64f0-461e-a604-7f6788384d12";
};
cryptrootUUID = lib.mkOption {
type = lib.types.str;
description = "The UUID of the decrypted root partition.";
default = "769362f6-43d4-4b83-a12c-d006c9bd6613";
};
};
mainUser = lib.mkOption {
type = lib.types.str;
description = "The main user of the machine";
default = "pml";
};
hostName = lib.mkOption {
type = lib.types.str;
description = "The name of the machine";
default = "persephone";
};
};
}
)
];
};
darwinConfigurations."hermes" = inputs.nix-darwin.lib.darwinSystem {
modules = [
{ system.configurationRevision = self.rev or self.dirtyRev or null; }
./machines/hermes.nix
(
{ lib, ... }:
{
options.machine = {
mainUser = lib.mkOption {
type = lib.types.str;
description = "The main user of the machine";
default = "pml";
};
hostName = lib.mkOption {
type = lib.types.str;
description = "The name of the machine";
default = "hermes";
};
};
}
)
];
};
devShells = forEachSupportedSystem (
{ pkgs, system }:
{
default = pkgs.mkShellNoCC {
packages = with pkgs; [
self.formatter.${system}
nixd
];
};
}
);
formatter = forEachSupportedSystem ({ pkgs, ... }: pkgs.nixfmt-rfc-style);
};
}