WIP
This commit is contained in:
parent
e06b409221
commit
92f83235e0
10 changed files with 382 additions and 159 deletions
290
flake.nix
290
flake.nix
|
|
@ -1,129 +1,176 @@
|
|||
{
|
||||
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 nixpkgs; };
|
||||
|
||||
lib = import ./lib { inherit (inputs.nixpkgs) lib; };
|
||||
pkgsFor =
|
||||
system:
|
||||
import inputs.nixpkgs {
|
||||
inherit system;
|
||||
config.allowUnfree = true;
|
||||
inherit (lib) forEachSupportedSystem pkgsFor;
|
||||
|
||||
systems =
|
||||
let
|
||||
inherit (inputs)
|
||||
home-manager
|
||||
lanzaboote
|
||||
nix-darwin
|
||||
nixpkgs
|
||||
;
|
||||
inherit (nixpkgs.lib)
|
||||
flatten
|
||||
hasSuffix
|
||||
mkAliasOptionModule
|
||||
strings
|
||||
;
|
||||
|
||||
systemFn =
|
||||
system:
|
||||
if hasSuffix "darwin" system then
|
||||
nix-darwin.lib.darwinSystem
|
||||
else if hasSuffix "linux" system then
|
||||
nixpkgs.lib.nixosSystem
|
||||
else
|
||||
throw "System: ${system} not supported.";
|
||||
|
||||
homeModule =
|
||||
system:
|
||||
if hasSuffix "darwin" system then
|
||||
home-manager.darwinModules.home-manager
|
||||
else if hasSuffix "linux" system then
|
||||
home-manager.nixosModules.home-manager
|
||||
else
|
||||
throw "System: ${system} not supported.";
|
||||
|
||||
in
|
||||
{
|
||||
mkSystem =
|
||||
system:
|
||||
{
|
||||
profile ? "minimal",
|
||||
machine ? { },
|
||||
modules ? [ ],
|
||||
specialArgs ? { },
|
||||
}:
|
||||
systemFn system {
|
||||
inherit specialArgs;
|
||||
|
||||
modules = flatten (
|
||||
modules
|
||||
++ [
|
||||
(
|
||||
if hasSuffix "darwin" system then
|
||||
home-manager.darwinModules.home-manager
|
||||
else if hasSuffix "linux" system then
|
||||
[
|
||||
home-manager.nixosModules.home-manager
|
||||
lanzaboote.nixosModules.lanzaboote
|
||||
]
|
||||
else
|
||||
throw "System: ${system} not supported."
|
||||
)
|
||||
|
||||
./modules/machine.nix
|
||||
./profiles/${strings.concatStrings (lib.drop 1 (strings.splitString "-" system))}/${profile}.nix
|
||||
./machines/${machine.hostName}/system.nix
|
||||
{
|
||||
imports = [
|
||||
(mkAliasOptionModule
|
||||
[ "hm" ]
|
||||
[
|
||||
"home-manager"
|
||||
"users"
|
||||
"${machine.mainUser}"
|
||||
]
|
||||
)
|
||||
];
|
||||
|
||||
config = {
|
||||
machine = machine;
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
}
|
||||
// lib.optionalAttrs (lib.hasSuffix "linux" system) {
|
||||
hm.home.homeDirectory = "/home/${machine.mainUser}";
|
||||
}
|
||||
// lib.optionalAttrs (lib.hasSuffix "darwin" system) {
|
||||
users.users.${machine.mainUser}.home = "/Users/pml";
|
||||
nixpkgs.config.allowUnfreePredicate =
|
||||
pkg:
|
||||
builtins.elem (lib.getName pkg) [
|
||||
"obsidian"
|
||||
];
|
||||
};
|
||||
}
|
||||
]
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
forEachSupportedSystem =
|
||||
f:
|
||||
inputs.nixpkgs.lib.genAttrs supportedSystems (
|
||||
system:
|
||||
f {
|
||||
inherit system;
|
||||
pkgs = pkgsFor system;
|
||||
}
|
||||
);
|
||||
mkDarwinSystem =
|
||||
{
|
||||
modules ? [ ],
|
||||
machine,
|
||||
specialArgs ? { },
|
||||
system ? { },
|
||||
home ? { },
|
||||
}:
|
||||
inputs.nix-darwin.lib.darwinSystem {
|
||||
specialArgs = specialArgs // {
|
||||
inherit inputs;
|
||||
};
|
||||
modules = [
|
||||
{ system.configurationRevision = self.rev or self.dirtyRev or null; }
|
||||
inputs.home-manager.darwinModules.home-manager
|
||||
./modules/machine.nix
|
||||
./machines/${machine.hostName}/system.nix
|
||||
{ config.machine = machine; }
|
||||
{
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
environment.etc = {
|
||||
"1password" = {
|
||||
target = "1password/custom_allowed_browsers";
|
||||
enable = true;
|
||||
text = ''
|
||||
firefox
|
||||
brave
|
||||
'';
|
||||
# mode = "0755";
|
||||
};
|
||||
};
|
||||
}
|
||||
(
|
||||
{ config, ... }:
|
||||
{
|
||||
users.users.pml.home = "/Users/pml";
|
||||
hm.home.username = "pml";
|
||||
}
|
||||
)
|
||||
]
|
||||
++ modules;
|
||||
};
|
||||
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";
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
];
|
||||
nixosConfigurations."persephone" = systems.mkSystem "x86_64-linux" {
|
||||
profile = "desktop";
|
||||
machine = {
|
||||
hostName = "persephone";
|
||||
mainUser = "pml";
|
||||
filesystem.uuid = {
|
||||
boot = "cb03cf78-715e-4030-ba82-189ff8897eaf";
|
||||
esp = "4E4C-1139";
|
||||
luks = "0cf52ea1-16d1-4dec-a69a-bdac82bbcf25";
|
||||
cryptroot = "6fb9ce3c-c870-4eb7-8199-6536ff898701";
|
||||
};
|
||||
};
|
||||
modules = [ ./home.nix ];
|
||||
};
|
||||
|
||||
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";
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
];
|
||||
darwinConfigurations."hermes" = systems.mkSystem "aarch64-darwin" {
|
||||
profile = "desktop";
|
||||
machine = {
|
||||
hostName = "hermes";
|
||||
mainUser = "pml";
|
||||
};
|
||||
modules = [ ./home.nix ];
|
||||
};
|
||||
|
||||
devShells = forEachSupportedSystem (
|
||||
|
|
@ -140,4 +187,17 @@
|
|||
|
||||
formatter = forEachSupportedSystem ({ pkgs, ... }: pkgs.nixfmt-rfc-style);
|
||||
};
|
||||
|
||||
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";
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue