refactor: create flake module for hosts/
This commit is contained in:
parent
6dda98201d
commit
8252e62c0c
100
flake.nix
100
flake.nix
|
@ -82,8 +82,12 @@ rec {
|
|||
outputs = { self, nixpkgs, nixpkgs-unstable, ... }@inputs:
|
||||
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
systems = [ "x86_64-linux" "aarch64-linux" ];
|
||||
imports =
|
||||
[ ./pkgs/flake-module.nix ./lib/flake-module.nix ./overlays.nix ];
|
||||
imports = [
|
||||
./pkgs/flake-module.nix
|
||||
./lib/flake-module.nix
|
||||
./hosts/flake-module.nix
|
||||
./overlays.nix
|
||||
];
|
||||
flake = {
|
||||
inherit nixConfig;
|
||||
|
||||
|
@ -99,96 +103,6 @@ rec {
|
|||
tor-browser = import ./home/modules/firefox/tor-browser.nix;
|
||||
mullvad-browser = import ./home/modules/firefox/mullvad-browser.nix;
|
||||
};
|
||||
|
||||
nixosConfigurations = {
|
||||
home-pc = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = [
|
||||
nixpkgs.nixosModules.notDetected
|
||||
inputs.nixos-hardware.nixosModules.common-pc
|
||||
inputs.nixos-hardware.nixosModules.common-pc-ssd
|
||||
inputs.nixos-hardware.nixosModules.common-cpu-amd-pstate
|
||||
inputs.nixos-hardware.nixosModules.common-gpu-amd
|
||||
(self.lib.createSystem "home-pc" {
|
||||
hardwareConfig = ./hardware/home-pc.nix;
|
||||
config = ./hosts/home-pc.nix;
|
||||
})
|
||||
self.lib.createMediaGroup
|
||||
(self.lib.createUser "felschr" {
|
||||
user.extraGroups =
|
||||
[ "wheel" "audio" "disk" "libvirtd" "qemu-libvirtd" "media" ];
|
||||
modules = [ self.homeManagerModules.git ];
|
||||
config = ./home/felschr.nix;
|
||||
usesContainers = true;
|
||||
})
|
||||
({ pkgs, ... }: {
|
||||
environment.systemPackages =
|
||||
[ inputs.deploy-rs.defaultPackage.x86_64-linux ];
|
||||
})
|
||||
];
|
||||
specialArgs = { inherit inputs; };
|
||||
};
|
||||
pilot1 = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = [
|
||||
nixpkgs.nixosModules.notDetected
|
||||
inputs.nixos-hardware.nixosModules.common-pc
|
||||
inputs.nixos-hardware.nixosModules.common-pc-ssd
|
||||
inputs.nixos-hardware.nixosModules.common-cpu-intel
|
||||
inputs.nixos-hardware.nixosModules.common-gpu-intel
|
||||
(self.lib.createSystem "pilot1" {
|
||||
hardwareConfig = ./hardware/pilot1.nix;
|
||||
config = ./hosts/work-pc.nix;
|
||||
})
|
||||
(self.lib.createUser "felschr" {
|
||||
user.extraGroups = [ "wheel" "audio" "disk" ];
|
||||
modules = [ self.homeManagerModules.git ];
|
||||
config = ./home/felschr-work.nix;
|
||||
usesContainers = true;
|
||||
})
|
||||
];
|
||||
specialArgs = { inherit inputs; };
|
||||
};
|
||||
home-server = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = [
|
||||
nixpkgs.nixosModules.notDetected
|
||||
inputs.nixos-hardware.nixosModules.common-pc
|
||||
inputs.nixos-hardware.nixosModules.common-pc-ssd
|
||||
inputs.nixos-hardware.nixosModules.common-cpu-intel-kaby-lake
|
||||
inputs.nixos-hardware.nixosModules.common-gpu-intel
|
||||
inputs.matrix-appservices.nixosModule
|
||||
(self.lib.createSystem "home-server" {
|
||||
hardwareConfig = ./hardware/lattepanda.nix;
|
||||
config = ./hosts/home-server.nix;
|
||||
})
|
||||
self.lib.createMediaGroup
|
||||
(self.lib.createUser "felschr" {
|
||||
user = {
|
||||
extraGroups = [ "wheel" "audio" "disk" "media" ];
|
||||
openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP751vlJUnB7Pfe1KNr6weWkx/rkP4J3lTYpAekHdOgV"
|
||||
];
|
||||
};
|
||||
modules = [ self.homeManagerModules.git ];
|
||||
config = ./home/felschr-server.nix;
|
||||
})
|
||||
];
|
||||
specialArgs = { inherit inputs; };
|
||||
};
|
||||
};
|
||||
|
||||
deploy.nodes.home-server = {
|
||||
hostname = "192.168.1.102";
|
||||
profiles.system = {
|
||||
sshUser = "felschr";
|
||||
sshOpts = [ "-t" ];
|
||||
user = "root";
|
||||
path = inputs.deploy-rs.lib.x86_64-linux.activate.nixos
|
||||
self.nixosConfigurations.home-server;
|
||||
magicRollback = false; # otherwise password prompt won't work
|
||||
};
|
||||
};
|
||||
};
|
||||
perSystem = { system, config, pkgs, ... }: {
|
||||
_module.args.pkgs = import nixpkgs {
|
||||
|
@ -199,7 +113,7 @@ rec {
|
|||
devShells.default =
|
||||
pkgs.mkShell { inherit (config.checks.pre-commit) shellHook; };
|
||||
|
||||
checks = inputs.deploy-rs.lib.${system}.deployChecks self.deploy // {
|
||||
checks = {
|
||||
pre-commit = inputs.pre-commit-hooks.lib.${system}.run {
|
||||
src = ./.;
|
||||
hooks = {
|
||||
|
|
103
hosts/flake-module.nix
Normal file
103
hosts/flake-module.nix
Normal file
|
@ -0,0 +1,103 @@
|
|||
{ self, inputs, ... }: {
|
||||
flake = {
|
||||
nixosConfigurations = {
|
||||
home-pc = inputs.nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = [
|
||||
inputs.nixpkgs.nixosModules.notDetected
|
||||
inputs.nixos-hardware.nixosModules.common-pc
|
||||
inputs.nixos-hardware.nixosModules.common-pc-ssd
|
||||
inputs.nixos-hardware.nixosModules.common-cpu-amd-pstate
|
||||
inputs.nixos-hardware.nixosModules.common-gpu-amd
|
||||
(self.lib.createSystem "home-pc" {
|
||||
hardwareConfig = ../hardware/home-pc.nix;
|
||||
config = ../hosts/home-pc.nix;
|
||||
})
|
||||
self.lib.createMediaGroup
|
||||
(self.lib.createUser "felschr" {
|
||||
user.extraGroups = [
|
||||
"wheel"
|
||||
"networkmanager"
|
||||
"audio"
|
||||
"disk"
|
||||
"libvirtd"
|
||||
"qemu-libvirtd"
|
||||
"media"
|
||||
];
|
||||
modules = [ self.homeManagerModules.git ];
|
||||
config = ../home/felschr.nix;
|
||||
usesContainers = true;
|
||||
})
|
||||
({ pkgs, ... }: {
|
||||
environment.systemPackages =
|
||||
[ inputs.deploy-rs.defaultPackage.x86_64-linux ];
|
||||
})
|
||||
];
|
||||
specialArgs = { inherit inputs; };
|
||||
};
|
||||
pilot1 = inputs.nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = [
|
||||
inputs.nixpkgs.nixosModules.notDetected
|
||||
inputs.nixos-hardware.nixosModules.common-pc
|
||||
inputs.nixos-hardware.nixosModules.common-pc-ssd
|
||||
inputs.nixos-hardware.nixosModules.common-cpu-intel
|
||||
inputs.nixos-hardware.nixosModules.common-gpu-intel
|
||||
(self.lib.createSystem "pilot1" {
|
||||
hardwareConfig = ../hardware/pilot1.nix;
|
||||
config = ../hosts/work-pc.nix;
|
||||
})
|
||||
(self.lib.createUser "felschr" {
|
||||
user.extraGroups = [ "wheel" "audio" "disk" ];
|
||||
modules = [ self.homeManagerModules.git ];
|
||||
config = ../home/felschr-work.nix;
|
||||
usesContainers = true;
|
||||
})
|
||||
];
|
||||
specialArgs = { inherit inputs; };
|
||||
};
|
||||
home-server = inputs.nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = [
|
||||
inputs.nixpkgs.nixosModules.notDetected
|
||||
inputs.nixos-hardware.nixosModules.common-pc
|
||||
inputs.nixos-hardware.nixosModules.common-pc-ssd
|
||||
inputs.nixos-hardware.nixosModules.common-cpu-intel-kaby-lake
|
||||
inputs.nixos-hardware.nixosModules.common-gpu-intel
|
||||
inputs.matrix-appservices.nixosModule
|
||||
(self.lib.createSystem "home-server" {
|
||||
hardwareConfig = ../hardware/lattepanda.nix;
|
||||
config = ../hosts/home-server.nix;
|
||||
})
|
||||
self.lib.createMediaGroup
|
||||
(self.lib.createUser "felschr" {
|
||||
user = {
|
||||
extraGroups = [ "wheel" "audio" "disk" "media" ];
|
||||
openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP751vlJUnB7Pfe1KNr6weWkx/rkP4J3lTYpAekHdOgV"
|
||||
];
|
||||
};
|
||||
modules = [ self.homeManagerModules.git ];
|
||||
config = ../home/felschr-server.nix;
|
||||
})
|
||||
];
|
||||
specialArgs = { inherit inputs; };
|
||||
};
|
||||
};
|
||||
|
||||
deploy.nodes.home-server = {
|
||||
hostname = "192.168.1.102";
|
||||
profiles.system = {
|
||||
sshUser = "felschr";
|
||||
sshOpts = [ "-t" ];
|
||||
user = "root";
|
||||
path = inputs.deploy-rs.lib.x86_64-linux.activate.nixos
|
||||
self.nixosConfigurations.home-server;
|
||||
magicRollback = false; # otherwise password prompt won't work
|
||||
};
|
||||
};
|
||||
};
|
||||
perSystem = { system, config, pkgs, ... }: {
|
||||
checks = inputs.deploy-rs.lib.${system}.deployChecks self.deploy;
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue