Skip to content

Commit

Permalink
overhaul modules, move to flake module
Browse files Browse the repository at this point in the history
  • Loading branch information
redxtech committed Mar 29, 2024
1 parent 8e89693 commit 349a155
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 168 deletions.
66 changes: 14 additions & 52 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,80 +51,42 @@
};

outputs = inputs@{ self, nixpkgs, home-manager, flake-parts, hardware, ... }:
let
realHostNames = [ "bastion" "voyager" "quasar" ];

extraSpecialArgs = {
inherit inputs realHostNames;
inherit (self) overlays;
};

modules = (import ./modules {
inherit inputs extraSpecialArgs;
inherit (self) nixosModules homeManagerModules lib overlays;
});
in flake-parts.lib.mkFlake { inherit inputs; } {
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
./modules/flake/deploy.nix
./modules/flake/nix.nix
./modules/flake/modules.nix
./modules/flake/overlays.nix
./modules/flake/shell.nix
];

systems = [ "x86_64-linux" "aarch64-linux" ];

flake = let lib = nixpkgs.lib // home-manager.lib;
in {
inherit lib;

nixosModules = import ./modules/nixos;
homeManagerModules = import ./modules/home-manager;

overlays = import ./overlays { inherit inputs; };

nixosConfigurations = let
specialArgs = {
inherit inputs realHostNames;
inherit (self) overlays homeManagerModules;
};
in {
flake = {
nixosConfigurations = {
# main desktop
bastion = lib.nixosSystem {
inherit specialArgs;
bastion = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = modules.nixos.bastion;
modules = [ self.nixosModules.bastion ];
};
# laptop
voyager = lib.nixosSystem {
inherit specialArgs;
voyager = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = modules.nixos.voyager;
modules = [ self.nixosModules.voyager ];
};
# nas & media server
quasar = lib.nixosSystem {
inherit specialArgs;
quasar = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = modules.nixos.quasar;
modules = [ self.nixosModules.quasar ];
};
# # raspi - ??
# gizmo = lib.nixosSystem {
# inherit specialArgs;
# modules = [ ./hosts/gizmo ] ++ commonModules;
# };
# # nixiso
# nixiso = lib.nixosSystem {
# inherit specialArgs;
# modules = [ ./hosts/nixiso ] ++ commonModules;
# system = "x86_64-linux";
# };
};

homeConfigurations = {
"gabe@deck" = lib.homeManagerConfiguration {
inherit extraSpecialArgs;
modules = modules.home-manager.deck;
"gabe@deck" = home-manager.lib.homeManagerConfiguration {
modules = [ self.homeManagerModules.deck ];
pkgs = import nixpkgs {
inherit (self.nixCfg.nixpkgs) config overlays;
system = "x86_64-linux";
config.allowUnfree = true;
};
};
};
Expand Down
66 changes: 0 additions & 66 deletions modules/default.nix

This file was deleted.

87 changes: 87 additions & 0 deletions modules/flake/modules.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{ self, inputs, lib, ... }:

let inherit (builtins) attrValues;
in {
flake = let
realHostNames = [ "bastion" "voyager" "quasar" ];

allNixos = import ../nixos;
allHomeManager = import ../home-manager;

homeCommon = [
inputs.hyprland.homeManagerModules.default
inputs.sops-nix.homeManagerModules.sops
inputs.nix-flatpak.homeManagerModules.nix-flatpak

{
config = {
inherit (self.nixCfg) nix;

_module.args = { inherit realHostNames; };
};
}
] ++ attrValues allHomeManager;

nixosCommon = [
inputs.home-manager.nixosModules.home-manager
inputs.hyprland.nixosModules.default
inputs.nh.nixosModules.default
inputs.nix-flatpak.nixosModules.nix-flatpak
inputs.solaar.nixosModules.default
inputs.sops-nix.nixosModules.sops
inputs.xremap-flake.nixosModules.default

../../hosts/common

{
config = {
inherit (self.nixCfg) nix nixpkgs;

_module.args = { inherit realHostNames; };

home-manager = {
sharedModules = homeCommon;
useGlobalPkgs = true;
};
};
}
] ++ attrValues allNixos;
in {
nixosModules = {
common = nixosCommon;

bastion.imports = [
../../hosts/bastion

inputs.hardware.nixosModules.common-cpu-amd
inputs.hardware.nixosModules.common-gpu-amd
inputs.hardware.nixosModules.common-pc-ssd

inputs.disko.nixosModules.disko
] ++ nixosCommon;

voyager.imports = [
../../hosts/voyager

inputs.hardware.nixosModules.dell-xps-15-7590-nvidia
inputs.hardware.nixosModules.common-cpu-intel-cpu-only
inputs.hardware.nixosModules.common-gpu-nvidia-nonprime
inputs.hardware.nixosModules.common-pc-ssd
] ++ nixosCommon;

quasar.imports = [
../../hosts/quasar

inputs.hardware.nixosModules.common-cpu-intel-cpu-only
inputs.hardware.nixosModules.common-gpu-nvidia-nonprime
inputs.hardware.nixosModules.common-pc-ssd
] ++ nixosCommon;
} // allNixos;

homeManagerModules = {
common = homeCommon;

deck.imports = [ ../../home/gabe/deck.nix ] ++ homeCommon;
} // allNixos;
};
}
55 changes: 55 additions & 0 deletions modules/flake/nix.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{ self, inputs, lib, ... }:

{
flake = {
nixCfg = {
nix = {
settings = {
trusted-users = [ "root" "@wheel" "gabe" ];
experimental-features = [ "nix-command" "flakes" "repl-flake" ];
substituters = [
"https://cache.nixos.org"
"https://nix-community.cachix.org"
"https://devenv.cachix.org"
"https://gabedunn.cachix.org"
"https://hyprland.cachix.org"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="
"gabedunn.cachix.org-1:wLWTKadNjpr2Op3rBnDZMUmUEPPIoKG87oY4PmBP8qU="
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
];
auto-optimise-store = lib.mkDefault true;
warn-dirty = false;
system-features = [ "kvm" "big-parallel" "nixos-test" ];
};
gc = {
automatic = true;
options = "--delete-older-than 5d";
};

# add each flake input as a registry
# to make nix3 commands consistent with the flake
registry = lib.mapAttrs (_: value: { flake = value; }) inputs;
};

nixpkgs = {
overlays = builtins.attrValues self.overlays;
config = {
allowUnfree = true;
permittedInsecurePackages = [ "electron-25.9.0" ];
nvidia.acceptLicense = true;
};
};
};
};

perSystem = { config, self', inputs', pkgs, system, ... }: {
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
inherit (self.nixCfg.nixpkgs) config overlays;
};
};
}
3 changes: 0 additions & 3 deletions modules/flake/overlays.nix
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@
neovim-nightly = inputs.neovim-nightly-overlay.overlay;
rust-overlay = inputs.rust-overlay.overlays.default;
# nur = inputs.nur.overlay;
# inputs.nix-minecraft.overlay
};
};

# perSystem = { config, self', inputs', pkgs, system, ... }: { };
}
2 changes: 1 addition & 1 deletion modules/nixos/base/cli.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ inputs, pkgs, lib, config, ... }:
{ pkgs, lib, config, ... }:

let
inherit (lib) mkIf;
Expand Down
2 changes: 1 addition & 1 deletion modules/nixos/base/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, lib, config, overlays, ... }:
{ pkgs, lib, config, ... }:

let
inherit (lib) mkIf mkDefault mkOption mkEnableOption optional;
Expand Down
45 changes: 0 additions & 45 deletions nix.nix

This file was deleted.

0 comments on commit 349a155

Please sign in to comment.