revamp of structure
This commit is contained in:
parent
275586f9c2
commit
b5365e6ab3
26 changed files with 383 additions and 393 deletions
145
flake.nix
145
flake.nix
|
|
@ -5,72 +5,89 @@
|
|||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||
home-manager.url = "github:nix-community/home-manager";
|
||||
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
||||
lanzaboote = {
|
||||
url = "github:nix-community/lanzaboote/v1.1.0";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
inputs.lanzaboote = {
|
||||
url = "github:nix-community/lanzaboote/v1.1.0";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = inputs@{ self, nixpkgs, home-manager, ... }:
|
||||
let
|
||||
filter = with nixpkgs.lib;
|
||||
folder: fileset.toList (fileset.fileFilter
|
||||
(file:
|
||||
hasSuffix "nix"
|
||||
file.name)
|
||||
folder);
|
||||
nixosConfig = {modules ? []}: nixpkgs.lib.nixosSystem {
|
||||
modules = modules;
|
||||
specialArgs = { inherit inputs filter home-manager; };
|
||||
};
|
||||
in
|
||||
{
|
||||
nixosConfigurations.p14s = nixosConfig {
|
||||
modules = [
|
||||
inputs.lanzaboote.nixosModules.lanzaboote
|
||||
./devices/p14s
|
||||
./styles/desktop.nix
|
||||
];
|
||||
};
|
||||
|
||||
apps.x86_64-linux.default = {
|
||||
type = "app";
|
||||
program = toString (nixpkgs.legacyPackages.x86_64-linux.writeShellScript "rebuild" ''
|
||||
exec sudo nixos-rebuild switch --flake . "$@"
|
||||
'');
|
||||
};
|
||||
|
||||
apps.x86_64-linux.registerDevice = {
|
||||
type = "app";
|
||||
program = toString (nixpkgs.legacyPackages.x86_64-linux.writeShellScript "rebuild" ''
|
||||
[ -d ./devices/$HOST ] && exit 1
|
||||
mkdir -p ./devices/$HOST
|
||||
nixos-generate-config --show-hardware-config > ./devices/$HOST/hardware-config.nix
|
||||
cat>./devices/$HOST/default.nix<<EOF
|
||||
{ ... }:
|
||||
{
|
||||
imports = [
|
||||
../../common
|
||||
./hardware-configuration.nix
|
||||
outputs =
|
||||
inputs@{
|
||||
self,
|
||||
nixpkgs,
|
||||
home-manager,
|
||||
lanzaboote,
|
||||
...
|
||||
}:
|
||||
let
|
||||
filter =
|
||||
with nixpkgs.lib;
|
||||
folder: fileset.toList (fileset.fileFilter (file: hasSuffix "nix" file.name) folder);
|
||||
nixosConfig =
|
||||
name:
|
||||
nixpkgs.lib.nixosSystem {
|
||||
modules = [
|
||||
lanzaboote.nixosModules.lanzaboote
|
||||
./modules/nixos
|
||||
./devices/${name}
|
||||
./users/strix
|
||||
];
|
||||
networking.hostName = "$HOST";
|
||||
system.stateVersion = "${nixpkgs.lib.trivial.release}"; # yes
|
||||
}
|
||||
EOF
|
||||
'');
|
||||
};
|
||||
specialArgs = {
|
||||
inherit
|
||||
inputs
|
||||
filter
|
||||
home-manager
|
||||
lanzaboote
|
||||
;
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
nixosConfigurations.p14s = nixosConfig "p14s";
|
||||
|
||||
devShells.x86_64-linux.default =
|
||||
let pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||
in pkgs.mkShell {
|
||||
shellHook = ''
|
||||
echo "Building VM..."
|
||||
rm -rf *.qcow2
|
||||
nixos-rebuild build-vm --flake . && ./result/bin/run-*-vm
|
||||
exit
|
||||
'';
|
||||
};
|
||||
apps.x86_64-linux.default = {
|
||||
type = "app";
|
||||
program = toString (
|
||||
nixpkgs.legacyPackages.x86_64-linux.writeShellScript "rebuild" ''
|
||||
exec sudo nixos-rebuild switch --flake . "$@"
|
||||
''
|
||||
);
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
apps.x86_64-linux.registerDevice = {
|
||||
type = "app";
|
||||
program = toString (
|
||||
nixpkgs.legacyPackages.x86_64-linux.writeShellScript "rebuild" ''
|
||||
[ -d ./devices/$HOST ] && exit 1
|
||||
mkdir -p ./devices/$HOST
|
||||
nixos-generate-config --show-hardware-config > ./devices/$HOST/hardware-config.nix
|
||||
cat>./devices/$HOST/default.nix<<EOF
|
||||
{ ... }:
|
||||
{
|
||||
imports = [
|
||||
../../common
|
||||
./hardware-configuration.nix
|
||||
];
|
||||
networking.hostName = "$HOST";
|
||||
system.stateVersion = "${nixpkgs.lib.trivial.release}"; # yes
|
||||
}
|
||||
EOF
|
||||
''
|
||||
);
|
||||
};
|
||||
|
||||
devShells.x86_64-linux.default =
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||
in
|
||||
pkgs.mkShell {
|
||||
shellHook = ''
|
||||
echo "Building VM..."
|
||||
rm -rf *.qcow2
|
||||
nixos-rebuild build-vm --flake . && ./result/bin/run-*-vm
|
||||
exit
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue