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
124
flake.nix
124
flake.nix
|
@ -17,18 +17,46 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
outputs = { self, nixpkgs, home-manager, nur, nixgl, sops-nix, ... }@inputs:
|
outputs = { self, nixpkgs, home-manager, nur, nixgl, sops-nix, ... }@inputs:
|
||||||
let
|
let
|
||||||
stateVersion = "23.11";
|
stateVersion = "23.11";
|
||||||
|
|
||||||
|
allSystems = [
|
||||||
|
"x86_64-linux" # 64bit AMD/Intel x86
|
||||||
|
"aarch64-linux" # 64bit ARM Linux
|
||||||
|
];
|
||||||
|
|
||||||
allSystems = [
|
forAllSystems = fn:
|
||||||
"x86_64-linux" # 64bit AMD/Intel x86
|
nixpkgs.lib.genAttrs allSystems
|
||||||
"aarch64-linux" # 64bit ARM Linux
|
(system: fn { pkgs = import nixpkgs { inherit system; }; });
|
||||||
];
|
|
||||||
|
createNixosSystem = { system, hostname, username ? "ephase" }: nixpkgs.lib.nixosSystem {
|
||||||
forAllSystems = fn:
|
system = system;
|
||||||
nixpkgs.lib.genAttrs allSystems
|
specialArgs = {
|
||||||
(system: fn { pkgs = import nixpkgs { inherit system; }; });
|
inherit stateVersion inputs;
|
||||||
in {
|
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 }: {
|
devShells = forAllSystems ({ pkgs }: {
|
||||||
default = pkgs.mkShell {
|
default = pkgs.mkShell {
|
||||||
name = "nixfiles";
|
name = "nixfiles";
|
||||||
|
@ -46,71 +74,19 @@ in {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
nixosConfigurations = {
|
nixosConfigurations = {
|
||||||
morty = nixpkgs.lib.nixosSystem {
|
morty = createNixosSystem { system = "x86_64-linux"; hostname = "morty"; };
|
||||||
system = "x86_64-linux";
|
mrmeeseeks = createNixosSystem { system = "x86_64-linux"; hostname = "mrmeeseeks";};
|
||||||
specialArgs = {
|
luci = createNixosSystem { system = "x86_64-linux"; hostname = "luci"; };
|
||||||
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
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
homeConfigurations = {
|
homeConfigurations = {
|
||||||
rick = home-manager.lib.homeManagerConfiguration {
|
"ephase@rick" = createHomeConfiguration { system = "aarch64-linux"; hostname = "rick";};
|
||||||
pkgs = import nixpkgs {
|
"ephase@luci" = createHomeConfiguration { system = "x86_64-linux"; hostname = "luci";};
|
||||||
system = "aarch64-linux";
|
"ephase@morty" = createHomeConfiguration { system = "x86_64-linux"; hostname = "morty";};
|
||||||
overlays = [ nixgl.overlay ];
|
"ephase@mrmeeseeks" = createHomeConfiguration { system = "x86_64-linux"; hostname = "mrmeeseeks";};
|
||||||
};
|
"yorick-barbanneau@work" = createHomeConfiguration {
|
||||||
extraSpecialArgs = {
|
system = "x86_64-linux";
|
||||||
inherit stateVersion inputs;
|
hostname = "work";
|
||||||
hostname = "rick";
|
username = "yorick-barbanneau";
|
||||||
username = "ephase";
|
|
||||||
};
|
|
||||||
modules = [
|
|
||||||
./home-manager/default.nix
|
|
||||||
];
|
|
||||||
};
|
|
||||||
work = home-manager.lib.homeManagerConfiguration {
|
|
||||||
pkgs = import nixpkgs {
|
|
||||||
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 = [
|
imports = [
|
||||||
inputs.sops-nix.homeManagerModules.sops
|
inputs.sops-nix.homeManagerModules.sops
|
||||||
./base.nix
|
../hosts/${hostname}/home-config.nix
|
||||||
../nixos/includes/system/overlay.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.
|
imports = [ # Include the results of the hardware scan.
|
||||||
../hosts/${hostname}/hardware-configuration.nix
|
../hosts/${hostname}/hardware-configuration.nix
|
||||||
|
@ -15,11 +15,9 @@
|
||||||
./includes/system/overlay.nix
|
./includes/system/overlay.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
nixpkgs.config.allowUnfree = true;
|
nixpkgs.config.allowUnfree = true;
|
||||||
|
|
||||||
|
boot.kernelPackages = pkgs.linuxPackages_latest;
|
||||||
boot.kernelPackages = pkgs.linuxPackages_latest;
|
|
||||||
networking.hostName = hostname;
|
networking.hostName = hostname;
|
||||||
|
|
||||||
console = {
|
console = {
|
||||||
|
@ -30,32 +28,10 @@
|
||||||
useXkbConfig = true; # use xkbOptions in tty.
|
useXkbConfig = true; # use xkbOptions in tty.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
git
|
git
|
||||||
zsh
|
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;
|
system.stateVersion = stateVersion;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,19 +17,19 @@ tasks:
|
||||||
sources:
|
sources:
|
||||||
- "**/*.nix"
|
- "**/*.nix"
|
||||||
|
|
||||||
build:*:
|
nixos:build:*:
|
||||||
vars:
|
vars:
|
||||||
TARGET: "{{index .MATCH 0}}"
|
TARGET: "{{index .MATCH 0}}"
|
||||||
cmds:
|
cmds:
|
||||||
- nixos-rebuild --flake .#{{.TARGET}} build
|
- nixos-rebuild --flake .#{{.TARGET}} build
|
||||||
|
|
||||||
switch:*:
|
nixos:switch:*:
|
||||||
vars:
|
vars:
|
||||||
TARGET: "{{index .MATCH 0}}"
|
TARGET: "{{index .MATCH 0}}"
|
||||||
cmds:
|
cmds:
|
||||||
- doas nixos-rebuild --flake .#{{.TARGET}} switch
|
- doas nixos-rebuild --flake .#{{.TARGET}} switch
|
||||||
|
|
||||||
test:*:
|
nixos:test:*:
|
||||||
vars:
|
vars:
|
||||||
TARGET: "{{index .MATCH 0}}"
|
TARGET: "{{index .MATCH 0}}"
|
||||||
cmds:
|
cmds:
|
||||||
|
@ -41,12 +41,6 @@ tasks:
|
||||||
cmds:
|
cmds:
|
||||||
- home-manager build --flake .#{{.TARGET}}
|
- home-manager build --flake .#{{.TARGET}}
|
||||||
|
|
||||||
home:test:*:
|
|
||||||
vars:
|
|
||||||
TARGET: "{{index .MATCH 0}}"
|
|
||||||
cmds:
|
|
||||||
- home-manager test --flake .#{{.TARGET}}
|
|
||||||
|
|
||||||
home:switch:*:
|
home:switch:*:
|
||||||
vars:
|
vars:
|
||||||
TARGET: "{{index .MATCH 0}}"
|
TARGET: "{{index .MATCH 0}}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue