Use haumea, shuffle things around

pull/50/head
Tudor Roman 2023-12-31 15:09:25 +02:00
parent fedcc8d778
commit 8d8d78e118
Signed by: tudor
SSH Key Fingerprint: SHA256:3CwS9plgXBecpXImPGxDIaSktUXBejbV/zerZMqzzBk
12 changed files with 165 additions and 111 deletions

View File

@ -186,6 +186,27 @@
"type": "github"
}
},
"haumea": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1685133229,
"narHash": "sha256-FePm/Gi9PBSNwiDFq3N+DWdfxFq0UKsVVTJS3cQPn94=",
"owner": "nix-community",
"repo": "haumea",
"rev": "34dd58385092a23018748b50f9b23de6266dffc2",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "v0.2.2",
"repo": "haumea",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
@ -407,6 +428,7 @@
"deploy-rs": "deploy-rs",
"flake-compat": "flake-compat_2",
"flake-parts": "flake-parts",
"haumea": "haumea",
"home-manager": "home-manager",
"hypr-contrib": "hypr-contrib",
"nixgl": "nixgl",

196
flake.nix
View File

@ -7,6 +7,10 @@
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
haumea = {
url = "github:nix-community/haumea/v0.2.2";
inputs.nixpkgs.follows = "nixpkgs";
};
deploy-rs = {
url = "github:serokell/deploy-rs";
@ -61,117 +65,122 @@
blog.url = "github:tudurom/blog";
};
outputs = inputs@{ self, nixpkgs, deploy-rs, unstable, flake-parts, ... }:
outputs = inputs@{ self, haumea, nixpkgs, deploy-rs, unstable, flake-parts, ... }:
let
vars = {
stateVersion = "23.11";
username = "tudor";
};
mkPkgs = pkgs: system: import pkgs {
inherit system;
config.allowUnfree = true;
overlays = [
(final: prev: {
unstable = import inputs.unstable { inherit system; config.allowUnfree = true; };
home-manager = inputs.home-manager.packages.${system}.home-manager;
})
];
};
mkHmDependencies = system: [
inputs.agenix.homeManagerModules.default
];
mkNixOSModules = name: system: [
{
nixpkgs.pkgs = mkPkgs nixpkgs system;
_module.args.nixpkgs = nixpkgs;
_module.args.self = self;
_module.args.inputs = inputs;
_module.args.configName = name;
_module.args.vars = vars;
}
inputs.agenix.nixosModules.default
{
environment.systemPackages = [ inputs.agenix.packages.${system}.default ];
# enable ssh host key generation
services.openssh.enable = true;
}
inputs.home-manager.nixosModules.home-manager
inputs.nixos-wsl.nixosModules.wsl
inputs.yarr-nix.nixosModules.default
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = false;
extraSpecialArgs = { inherit inputs vars; configName = name; };
sharedModules = mkHmDependencies system;
};
}
./hosts/${name}
];
mkNixOSSystem = name: system: nixpkgs.lib.nixosSystem {
inherit system;
modules = mkNixOSModules name system;
};
mkNonNixOSEnvironment = name: user: system: inputs.home-manager.lib.homeManagerConfiguration {
pkgs = mkPkgs nixpkgs system;
extraSpecialArgs = {inherit inputs vars; configName = "normal-linux"; };
modules = (mkHmDependencies system) ++ [
{
_module.args.nixpkgs = nixpkgs;
_module.args.inputs = inputs;
_module.args.vars = vars;
}
{
home = {
homeDirectory = "/home/${user}";
username = user;
sessionVariables = {
GIT_SSH = "/usr/bin/ssh";
};
};
programs.bash.profileExtra = ''
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
'';
}
(./users + "/${name}")
];
};
mkDeployPkgs = system: import nixpkgs {
inherit system;
overlays = [
deploy-rs.overlay
(self: super: {
deploy-rs = {
inherit (nixpkgs.legacyPackages."${system}") deploy-rs;
lib = super.deploy-rs.lib;
};
})
];
specialArgs = {
inherit vars;
flake = {
inherit self inputs;
};
};
in flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" "aarch64-linux" ];
flake = {
nixosConfigurations."ceres" = mkNixOSSystem "ceres" "x86_64-linux";
nixosConfigurations."wsl2" = mkNixOSSystem "wsl2" "x86_64-linux";
lib = haumea.lib.load {
src = ./lib;
inputs = {
inherit nixpkgs inputs;
};
};
nixosConfigurations = let
mkNixOSSystem = name: system: let
modules = [
{
nixpkgs = {
config = self.lib.nixpkgs.defaultConfig;
overlays = self.lib.nixpkgs.mkDefaultOverlays { inherit system; };
};
}
inputs.agenix.nixosModules.default
{
environment.systemPackages = [ inputs.agenix.packages.${system}.default ];
# enable ssh host key generation
services.openssh.enable = true;
}
inputs.home-manager.nixosModules.home-manager
inputs.nixos-wsl.nixosModules.wsl
inputs.yarr-nix.nixosModules.default
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = false;
extraSpecialArgs = specialArgs // { configName = name; };
sharedModules = self.lib.hm-modules;
};
}
./hosts/${name}
];
in nixpkgs.lib.nixosSystem {
inherit system modules specialArgs;
};
in {
"ceres" = mkNixOSSystem "ceres" "x86_64-linux";
"wsl2" = mkNixOSSystem "wsl2" "x86_64-linux";
};
packages."x86_64-linux"."tudor" = self.homeConfigurations."tudor".activationPackage;
packages."x86_64-linux"."tudor@pepper-penguin" = self.homeConfigurations."tudor@pepper-penguin".activationPackage;
homeConfigurations."tudor" = mkNonNixOSEnvironment "tudor" "tudor" "x86_64-linux";
homeConfigurations."tudor@pepper-penguin" = mkNonNixOSEnvironment "tudor@pepper-penguin" "tudor" "x86_64-linux";
homeConfigurations = let
mkHomeConfiguration = name: user: system: let
pkgs = self.lib.nixpkgs.mkPkgs { inherit system; };
in inputs.home-manager.lib.homeManagerConfiguration {
inherit pkgs;
deploy.nodes."ceres" = {
extraSpecialArgs = specialArgs // { configName = "normal-linux"; };
modules = (self.lib.hm-modules) ++ [
{
nixpkgs = {
config = self.lib.nixpkgs.defaultConfig;
overlays = self.lib.nixpkgs.mkDefaultOverlays { inherit system; };
};
}
{
home = {
homeDirectory = "/home/${user}";
username = user;
sessionVariables = {
GIT_SSH = "/usr/bin/ssh";
};
};
programs.bash.profileExtra = ''
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
'';
}
(./users + "/${name}")
];
};
in {
"tudor" = mkHomeConfiguration "tudor" "tudor" "x86_64-linux";
"tudor@pepper-penguin" = mkHomeConfiguration "tudor@pepper-penguin" "tudor" "x86_64-linux";
};
deploy.nodes."ceres" = let
mkDeployPkgs = system: import nixpkgs {
inherit system;
overlays = [
deploy-rs.overlay
(self: super: {
deploy-rs = {
inherit (nixpkgs.legacyPackages."${system}") deploy-rs;
lib = super.deploy-rs.lib;
};
})
];
};
configuration = self.nixosConfigurations."ceres";
in {
hostname = "ceres.lamb-monitor.ts.net";
profiles.system = {
user = "root";
path = (mkDeployPkgs "x86_64-linux").deploy-rs.lib.activate.nixos self.nixosConfigurations."ceres";
path = (mkDeployPkgs configuration.pkgs.system).deploy-rs.lib.activate.nixos configuration;
};
};
};
@ -187,7 +196,6 @@
];
};
in {
_module.args.pkgs = mkPkgs nixpkgs system;
apps.deploy-rs = {
type = "app";
program = "${deployPkgs.deploy-rs.deploy-rs}/bin/deploy";

View File

@ -1,4 +1,4 @@
{ config, lib, pkgs, nixpkgs, self, inputs, vars, ... }:
{ flake, vars, ... }:
{
imports = [
@ -37,5 +37,5 @@
};
system.stateVersion = vars.stateVersion;
system.configurationRevision = self.rev or "dirty";
system.configurationRevision = flake.self.rev or "dirty";
}

3
lib/hm-modules.nix Normal file
View File

@ -0,0 +1,3 @@
{ inputs }: [
inputs.agenix.homeManagerModules.default
]

21
lib/nixpkgs.nix Normal file
View File

@ -0,0 +1,21 @@
{ self, inputs, ... }:
{
defaultConfig = {
allowUnfree = true;
};
mkDefaultOverlays = { system }: [
(final: prev: {
unstable = import inputs.unstable {
inherit system;
config = self.defaultConfig;
};
})
];
mkPkgs = { system }: import inputs.nixpkgs {
inherit system;
config = self.defaultConfig;
overlays = self.mkDefaultOverlays { inherit system; };
};
}

View File

@ -1,4 +1,4 @@
{ config, inputs, lib, pkgs, ... }:
{ config, flake, lib, pkgs, ... }:
let
cfg = config.homeModules.desktop.sway;
themeFont = config.homeModules.desktop.fonts.themeFont;
@ -26,7 +26,7 @@ with lib; {
config = mkIf cfg.enable {
nixpkgs.overlays = [
inputs.hypr-contrib.overlays.default
flake.inputs.hypr-contrib.overlays.default
];
homeModules.desktop = {

View File

@ -1,4 +1,4 @@
{ config, lib, pkgs, inputs, ... }:
{ config, lib, flake, ... }:
let
cfg = config.homeModules.tools.nix;
in
@ -10,6 +10,6 @@ with lib; {
};
config = mkIf cfg.enable {
nix.registry.stable.flake = inputs.nixpkgs;
nix.registry.stable.flake = flake.inputs.nixpkgs;
};
}

View File

@ -1,4 +1,4 @@
{ config, lib, pkgs, nixpkgs, self, vars, configName, ... }:
{ config, lib, pkgs, flake, ... }:
with lib;
let
@ -35,7 +35,7 @@ in
type = "indirect";
};
to = {
path = "${nixpkgs}";
path = "${flake.inputs.nixpkgs}";
type = "path";
};
};

View File

@ -1,4 +1,4 @@
{ config, pkgs, lib, ... }:
{ config, pkgs, lib, flake, ... }:
let
cfg = config.systemModules.services.pong;
in
@ -11,7 +11,7 @@ with lib;
config = mkIf cfg.enable {
nixpkgs.overlays = [
(final: prev: {
tudor.pong = inputs.co-work.packages.${final.system}.pong;
tudor.pong = flake.inputs.co-work.packages.${final.system}.pong;
})
];

View File

@ -1,4 +1,4 @@
{ config, pkgs, lib, inputs, ... }:
{ config, pkgs, lib, flake, ... }:
let
cfg = config.systemModules.services.web.site;
in
@ -14,8 +14,8 @@ with lib; {
in {
# https://discourse.nixos.org/t/namespacing-scoping-a-group-of-packages/13782/10
# I couldn't be bothered
tudorSite = inputs.site.packages.${system}.site;
tudorBlog = inputs.blog.packages.${system}.blog;
tudorSite = flake.inputs.site.packages.${system}.site;
tudorBlog = flake.inputs.blog.packages.${system}.blog;
})
];

View File

@ -1,4 +1,4 @@
{ config, lib, inputs, ... }:
{ config, lib, flake, ... }:
let
cfg = config.systemModules.services.web.yarr;
in
@ -7,7 +7,7 @@ with lib; {
config = mkIf cfg.enable {
nixpkgs.overlays = [
inputs.yarr-nix.overlays.default
flake.inputs.yarr-nix.overlays.default
];
services.yarr = {
enable = true;

View File

@ -1,4 +1,4 @@
{ pkgs, inputs, ... }:
{ pkgs, flake, ... }:
let
nixGLPackage = pkgs.nixgl.nixGLIntel;
laptopScreen = {
@ -17,7 +17,7 @@ let
in {
imports = [ ../tudor ];
nixpkgs.overlays = [
inputs.nixgl.overlays.default
flake.inputs.nixgl.overlays.default
];
home.packages = [ nixGLPackage ];