Skip to content

Commit

Permalink
refactor(hosts): changed structure of importing module for lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Wittano committed Jan 3, 2024
1 parent b296483 commit ceabe16
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 43 deletions.
28 changes: 2 additions & 26 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,47 +28,23 @@
{ self
, nixpkgs
, home-manager
, nixpkgs-unstable
, wittano-dotfiles
, system-staff
, emacs-overlay
, ...
}@inputs:
let
inherit (lib.my.hosts) mkHost;
inherit (lib.my.mapper) mapDirToAttrs;

system = "x86_64-linux";

mkPkgs = p:
import p {
inherit system;

overlays = [ emacs-overlay.overlay ];

config = {
allowUnfree = true;
};
};

pkgs = mkPkgs nixpkgs;
unstable = mkPkgs nixpkgs-unstable;

dotfiles = mapDirToAttrs wittano-dotfiles;

systemStaff = mapDirToAttrs system-staff;

lib = nixpkgs.lib.extend (sefl: super: {
hm = home-manager.lib.hm;
my = import ./lib {
inherit lib pkgs system home-manager unstable dotfiles systemStaff inputs;
inherit lib system inputs;
};
});
in
{
nixosConfigurations =
let
inherit (lib.attrsets) mapAttrs' nameValuePair;
inherit (lib.my.hosts) mkHost;

hosts = builtins.readDir ./hosts;
devHosts = mapAttrs'
Expand Down
2 changes: 1 addition & 1 deletion hosts/laptop/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
desktop = {
qtile = enableWithDevMode;
};
editors.neovim = enableWithDevMode;
editors.neovim.enable = true;
dev = {
goland.enable = true;
clion.enable = true;
Expand Down
29 changes: 25 additions & 4 deletions lib/default.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
{ lib, system, home-manager, pkgs, unstable, dotfiles, systemStaff, inputs, ... }:
{ lib
, system
, inputs
, ...
}:
let
ownPackages = inputs.wittano-repo.packages.x86_64-linux;
mkPkgs = p:
import p {
inherit system;

config.allowUnfree = true;
};

pkgs = mkPkgs inputs.nixpkgs;
unstable = mkPkgs inputs.nixpkgs-unstable;

mapper = import ./mapper.nix { inherit lib; };
imports = import ./imports.nix { inherit lib; };

dotfiles = mapper.mapDirToAttrs inputs.wittano-dotfiles;
systemStaff = mapper.mapDirToAttrs inputs.system-staff;

home-manager = inputs.home-manager;
in
{
hosts = import ./hosts.nix { inherit lib system home-manager pkgs unstable dotfiles systemStaff inputs ownPackages; };
mapper = import ./mapper.nix { inherit lib; };
inherit mapper imports;

hosts = import ./hosts.nix { inherit lib system pkgs unstable dotfiles systemStaff inputs ownPackages imports; };
link = import ./link.nix { inherit lib; };
apps = import ./apps.nix { inherit lib home-manager pkgs dotfiles ownPackages; };
imports = import ./imports.nix { inherit lib; };
}
19 changes: 11 additions & 8 deletions lib/hosts.nix
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
{ lib, system, home-manager, unstable, pkgs, dotfiles, systemStaff, inputs, ownPackages, ... }:
with lib;
with lib.my; {
{ lib, system, pkgs, unstable, dotfiles, systemStaff, ownPackages, inputs, imports, ... }: {
mkHost = { name, isDevMode ? false, username ? "wittano" }:
nixosSystem rec {
inputs.nixpkgs.lib.nixosSystem rec {
inherit system;

specialArgs = {
inherit pkgs unstable lib dotfiles isDevMode systemStaff username inputs ownPackages;
hostName = name;
agenix = inputs.agenix;
aagl = inputs.aagl;
# TODO Set option for other keys for diffrent hosts
secretsFile = ./../secrets/syncthing.age;
};

modules =
let hostName = builtins.replaceStrings [ "-dev" ] [ "" ] name;
let
hostName = builtins.replaceStrings [ "-dev" ] [ "" ] name;
defaultModule = { modulesPath, ... }: {
imports = [
(modulesPath + "/profiles/minimal.nix")
];
};
in
[
./../configuration.nix
Expand All @@ -25,7 +27,8 @@ with lib.my; {
inputs.agenix.nixosModules.default
inputs.nixvim.nixosModules.nixvim
inputs.aagl.nixosModules.default
home-manager.nixosModules.home-manager
inputs.home-manager.nixosModules.home-manager
defaultModule
] ++ (imports.importModulesPath ./../modules);
};
}
4 changes: 2 additions & 2 deletions modules/agenix.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{ config, agenix, lib, secretsFile, ... }:
{ config, lib, secretsFile, inputs, ... }:
with lib;
with lib.my;
let
privateKeyPath = "/home/wittano/.ssh/syncthing";
in
{
environment.systemPackages = [ agenix.packages.x86_64-linux.default ];
environment.systemPackages = [ inputs.agenix.packages.x86_64-linux.default ];

age = mkIf (config.modules.services.syncthing.enable) {
identityPaths = [ privateKeyPath ];
Expand Down
4 changes: 2 additions & 2 deletions modules/desktop/gaming/gaming.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ config, pkgs, home-manager, lib, unstable, aagl, ... }:
{ config, pkgs, home-manager, lib, unstable, inputs, ... }:
with lib;
let
cfg = config.modules.desktop.gaming;
Expand All @@ -19,7 +19,7 @@ in
};

config = mkIf cfg.enable {
nix.settings = mkIf cfg.enableMihoyoGames aagl.nixConfig;
nix.settings = mkIf cfg.enableMihoyoGames inputs.aagl.nixConfig;

# Genshin Impact
programs.anime-game-launcher.enable = cfg.enableMihoyoGames;
Expand Down

0 comments on commit ceabe16

Please sign in to comment.