refactor: separate NixOS and Home-Manager configuration
This commit is contained in:
parent
9edca93fd5
commit
d446f84030
5 changed files with 75 additions and 127 deletions
100
flake.nix
100
flake.nix
|
@ -17,7 +17,7 @@
|
|||
};
|
||||
};
|
||||
outputs = { self, nixpkgs, home-manager, nur, nixgl, sops-nix, ... }@inputs:
|
||||
let
|
||||
let
|
||||
stateVersion = "23.11";
|
||||
|
||||
allSystems = [
|
||||
|
@ -28,7 +28,35 @@ let
|
|||
forAllSystems = fn:
|
||||
nixpkgs.lib.genAttrs allSystems
|
||||
(system: fn { pkgs = import nixpkgs { inherit system; }; });
|
||||
in {
|
||||
|
||||
createNixosSystem = { system, hostname, username ? "ephase" }: nixpkgs.lib.nixosSystem {
|
||||
system = system;
|
||||
specialArgs = {
|
||||
inherit stateVersion inputs;
|
||||
hostname = hostname;
|
||||
username = username;
|
||||
};
|
||||
modules = [
|
||||
./nixos/default.nix
|
||||
];
|
||||
};
|
||||
|
||||
createHomeConfiguration = { system ? "x86_64-linux", hostname, username ? "ephase" }:
|
||||
home-manager.lib.homeManagerConfiguration {
|
||||
pkgs = import nixpkgs {
|
||||
system = system;
|
||||
overlays = [ nixgl.overlay ];
|
||||
};
|
||||
extraSpecialArgs = {
|
||||
inherit stateVersion inputs;
|
||||
hostname = hostname;
|
||||
username = username;
|
||||
};
|
||||
modules = [
|
||||
./home-manager/default.nix
|
||||
];
|
||||
};
|
||||
in {
|
||||
devShells = forAllSystems ({ pkgs }: {
|
||||
default = pkgs.mkShell {
|
||||
name = "nixfiles";
|
||||
|
@ -46,72 +74,20 @@ in {
|
|||
};
|
||||
});
|
||||
nixosConfigurations = {
|
||||
morty = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
specialArgs = {
|
||||
inherit stateVersion inputs;
|
||||
hostname = "morty";
|
||||
username = "ephase";
|
||||
};
|
||||
modules = [
|
||||
./nixos/default.nix
|
||||
home-manager.nixosModule
|
||||
];
|
||||
};
|
||||
mrmeeseeks = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
specialArgs = {
|
||||
inherit stateVersion inputs;
|
||||
hostname = "mrmeeseeks";
|
||||
username = "ephase";
|
||||
};
|
||||
modules = [
|
||||
./nixos/default.nix
|
||||
home-manager.nixosModule
|
||||
];
|
||||
};
|
||||
luci = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
specialArgs = {
|
||||
inherit stateVersion inputs;
|
||||
hostname = "luci";
|
||||
username = "ephase";
|
||||
};
|
||||
modules = [
|
||||
./nixos/default.nix
|
||||
home-manager.nixosModule
|
||||
];
|
||||
};
|
||||
morty = createNixosSystem { system = "x86_64-linux"; hostname = "morty"; };
|
||||
mrmeeseeks = createNixosSystem { system = "x86_64-linux"; hostname = "mrmeeseeks";};
|
||||
luci = createNixosSystem { system = "x86_64-linux"; hostname = "luci"; };
|
||||
};
|
||||
homeConfigurations = {
|
||||
rick = home-manager.lib.homeManagerConfiguration {
|
||||
pkgs = import nixpkgs {
|
||||
system = "aarch64-linux";
|
||||
overlays = [ nixgl.overlay ];
|
||||
};
|
||||
extraSpecialArgs = {
|
||||
inherit stateVersion inputs;
|
||||
hostname = "rick";
|
||||
username = "ephase";
|
||||
};
|
||||
modules = [
|
||||
./home-manager/default.nix
|
||||
];
|
||||
};
|
||||
work = home-manager.lib.homeManagerConfiguration {
|
||||
pkgs = import nixpkgs {
|
||||
"ephase@rick" = createHomeConfiguration { system = "aarch64-linux"; hostname = "rick";};
|
||||
"ephase@luci" = createHomeConfiguration { system = "x86_64-linux"; hostname = "luci";};
|
||||
"ephase@morty" = createHomeConfiguration { system = "x86_64-linux"; hostname = "morty";};
|
||||
"ephase@mrmeeseeks" = createHomeConfiguration { system = "x86_64-linux"; hostname = "mrmeeseeks";};
|
||||
"yorick-barbanneau@work" = createHomeConfiguration {
|
||||
system = "x86_64-linux";
|
||||
overlays = [ nixgl.overlay ];
|
||||
};
|
||||
extraSpecialArgs = {
|
||||
inherit stateVersion inputs;
|
||||
hostname = "work";
|
||||
username = "yorick-barbanneau";
|
||||
};
|
||||
modules = [
|
||||
./home-manager/default.nix
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,13 +1,4 @@
|
|||
{ lib, hostname, ...}:
|
||||
_:
|
||||
{
|
||||
programs.home-manager.enable = true;
|
||||
home.sessionPath = [
|
||||
"$HOME/.local/bin"
|
||||
];
|
||||
imports = [
|
||||
../hosts/${hostname}/home-config.nix
|
||||
../modules/home-manager/default.nix
|
||||
] ++ lib.optional (
|
||||
builtins.pathExists ../hosts/${hostname}/includes/home-manager.nix
|
||||
) ../hosts/${hostname}/includes/home-manager.nix;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,23 @@
|
|||
{ stateVersion, username, inputs, ... }:
|
||||
{ inputs, lib, stateVersion, username, hostname, ... }:
|
||||
{
|
||||
home.stateVersion = stateVersion;
|
||||
home.username = "${username}";
|
||||
home.homeDirectory = "/home/${username}";
|
||||
fonts.fontconfig.enable = true;
|
||||
imports = [
|
||||
inputs.sops-nix.homeManagerModules.sops
|
||||
./base.nix
|
||||
../hosts/${hostname}/home-config.nix
|
||||
../nixos/includes/system/overlay.nix
|
||||
../modules/home-manager/default.nix
|
||||
] ++ lib.optional (
|
||||
builtins.pathExists ../hosts/${hostname}/includes/home-manager.nix
|
||||
) ../hosts/${hostname}/includes/home-manager.nix;
|
||||
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
programs.home-manager.enable = true;
|
||||
fonts.fontconfig.enable = true;
|
||||
|
||||
home = {
|
||||
inherit stateVersion username;
|
||||
homeDirectory = "/home/${username}";
|
||||
sessionPath = [
|
||||
"$HOME/.local/bin"
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ inputs, pkgs, stateVersion, hostname, username, hostConfig, ... }:
|
||||
{ pkgs, stateVersion, hostname, ... }:
|
||||
{
|
||||
imports = [ # Include the results of the hardware scan.
|
||||
../hosts/${hostname}/hardware-configuration.nix
|
||||
|
@ -15,11 +15,9 @@
|
|||
./includes/system/overlay.nix
|
||||
];
|
||||
|
||||
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
|
||||
|
||||
boot.kernelPackages = pkgs.linuxPackages_latest;
|
||||
boot.kernelPackages = pkgs.linuxPackages_latest;
|
||||
networking.hostName = hostname;
|
||||
|
||||
console = {
|
||||
|
@ -30,32 +28,10 @@
|
|||
useXkbConfig = true; # use xkbOptions in tty.
|
||||
};
|
||||
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
git
|
||||
zsh
|
||||
];
|
||||
|
||||
home-manager = {
|
||||
useGlobalPkgs = true;
|
||||
useUserPackages = true;
|
||||
extraSpecialArgs = {
|
||||
inherit hostConfig;
|
||||
inherit hostname;
|
||||
};
|
||||
|
||||
# NixOS system-wide home-manager configuration
|
||||
sharedModules = [
|
||||
inputs.sops-nix.homeManagerModules.sops
|
||||
];
|
||||
|
||||
users.${username} = {
|
||||
home.stateVersion = stateVersion;
|
||||
imports = [
|
||||
../home-manager/base.nix
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
system.stateVersion = stateVersion;
|
||||
}
|
||||
|
|
|
@ -17,19 +17,19 @@ tasks:
|
|||
sources:
|
||||
- "**/*.nix"
|
||||
|
||||
build:*:
|
||||
nixos:build:*:
|
||||
vars:
|
||||
TARGET: "{{index .MATCH 0}}"
|
||||
cmds:
|
||||
- nixos-rebuild --flake .#{{.TARGET}} build
|
||||
|
||||
switch:*:
|
||||
nixos:switch:*:
|
||||
vars:
|
||||
TARGET: "{{index .MATCH 0}}"
|
||||
cmds:
|
||||
- doas nixos-rebuild --flake .#{{.TARGET}} switch
|
||||
|
||||
test:*:
|
||||
nixos:test:*:
|
||||
vars:
|
||||
TARGET: "{{index .MATCH 0}}"
|
||||
cmds:
|
||||
|
@ -41,12 +41,6 @@ tasks:
|
|||
cmds:
|
||||
- home-manager build --flake .#{{.TARGET}}
|
||||
|
||||
home:test:*:
|
||||
vars:
|
||||
TARGET: "{{index .MATCH 0}}"
|
||||
cmds:
|
||||
- home-manager test --flake .#{{.TARGET}}
|
||||
|
||||
home:switch:*:
|
||||
vars:
|
||||
TARGET: "{{index .MATCH 0}}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue