Skip to content

Commit

Permalink
Merge pull request #27 from michaelvanstraten/simplify-arg-passing
Browse files Browse the repository at this point in the history
Refactor Nix configurations to simplify argument passing and module i…
  • Loading branch information
michaelvanstraten authored Oct 6, 2024
2 parents 6cc008a + c5ddab5 commit 489416f
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 57 deletions.
6 changes: 1 addition & 5 deletions checks/default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{
system,
pre-commit-hooks,
pkgs,
}:
{ system, pre-commit-hooks, ... }:
{
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
Expand Down
16 changes: 4 additions & 12 deletions darwinConfigurations/default.nix
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
{
inputs,
nix-darwin,
home-manager,
...
}:
{ nix-darwin, home-manager, ... }@args:

{
"MacBook-Pro-von-Michael" = nix-darwin.lib.darwinSystem {
system = "aarch64-darwin";
modules = [
home-manager.darwinModule
hosts/personal-macbook-pro.nix
];
specialArgs = {
inherit inputs;
};
specialArgs = args;
};
"N7R221P6V5" = nix-darwin.lib.darwinSystem {
system = "aarch64-darwin";
modules = [
home-manager.darwinModule
hosts/mozilla-macbook-pro.nix
];
specialArgs = {
inherit inputs;
};
specialArgs = args;
};
}
6 changes: 2 additions & 4 deletions darwinConfigurations/modules/home-manager.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{ inputs, ... }:
{ specialArgs, ... }:
{
home-manager = {
backupFileExtension = "before-home-manager";
extraSpecialArgs = {
inherit inputs;
};
extraSpecialArgs = specialArgs;
useGlobalPkgs = true;
useUserPackages = true;
verbose = true;
Expand Down
4 changes: 2 additions & 2 deletions darwinConfigurations/modules/packages.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ inputs, pkgs, ... }:
{ nixpkgs-firefox-darwin, pkgs, ... }:
{
nixpkgs = {
overlays = with inputs; [ nixpkgs-firefox-darwin.overlay ];
overlays = [ nixpkgs-firefox-darwin.overlay ];
};

environment.systemPackages = with pkgs; [
Expand Down
17 changes: 17 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 33 additions & 18 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,37 +1,50 @@
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
pre-commit-hooks.url = "github:cachix/git-hooks.nix";
BetterFox = {
url = "github:yokoffing/BetterFox";
flake = false;
};

nix-darwin = {
url = "github:lnl7/nix-darwin";
cyberdream-theme = {
url = "github:scottmckendry/cyberdream.nvim";
flake = false;
};

disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};

flake-utils = {
url = "github:numtide/flake-utils";
};

home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};

cyberdream-theme = {
url = "github:scottmckendry/cyberdream.nvim";
flake = false;
};

neovim-nightly-overlay = {
url = "github:nix-community/neovim-nightly-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};

nix-darwin = {
url = "github:lnl7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};

nixpkgs = {
url = "github:nixos/nixpkgs/nixos-unstable";
};

nixpkgs-firefox-darwin = {
url = "github:bandithedoge/nixpkgs-firefox-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};

disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
pre-commit-hooks = {
url = "github:cachix/git-hooks.nix";
};
};

Expand All @@ -45,11 +58,13 @@
home-manager,
...
}@inputs:
let
callModule = modulePath: extraArgs: import modulePath (self.outputs // inputs // extraArgs);
in
{
darwinConfigurations = import ./darwinConfigurations { inherit inputs nix-darwin home-manager; };

nixosConfigurations = import ./nixosConfigurations { inherit self inputs nixpkgs; };
nixosModules = import ./nixosModules { inherit nixpkgs; };
darwinConfigurations = callModule ./darwinConfigurations { };
nixosConfigurations = callModule ./nixosConfigurations { };
nixosModules = callModule ./nixosModules { };
}
// flake-utils.lib.eachDefaultSystem (
system:
Expand All @@ -58,7 +73,7 @@
in
{
# Checks pre-commit-hooks
checks = import ./checks { inherit system pre-commit-hooks pkgs; };
checks = callModule ./checks { inherit system; };

# Development shell with necessary tools
devShells =
Expand Down
4 changes: 2 additions & 2 deletions homeConfigurations/modules/Alacritty.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{ inputs, pkgs, ... }:
{ cyberdream-theme, pkgs, ... }:
{
fonts.fontconfig.enable = true;
home.packages = [ pkgs.nerdfonts ];
programs.alacritty = {
enable = true;
settings = {
import = [ "${inputs.cyberdream-theme}/extras/alacritty/cyberdream.toml" ];
import = [ "${cyberdream-theme}/extras/alacritty/cyberdream.toml" ];
font = {
size = 14;
normal = {
Expand Down
4 changes: 2 additions & 2 deletions homeConfigurations/modules/Firefox.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ inputs, config, ... }:
{ BetterFox, config, ... }:
{
programs.firefox = {
# Let Firefox package be managed by the system
Expand All @@ -25,7 +25,7 @@
"browser.translations.enable" = false;
};

extraConfig = builtins.readFile "${inputs.BetterFox}/user.js";
extraConfig = builtins.readFile "${BetterFox}/user.js";
};
};
}
4 changes: 2 additions & 2 deletions homeConfigurations/modules/nvim/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ inputs, pkgs, ... }:
{ neovim-nightly-overlay, pkgs, ... }:
{
home.file.".config/nvim".source = ./.;

home.packages = [ inputs.neovim-nightly-overlay.packages.${pkgs.system}.default ];
home.packages = [ neovim-nightly-overlay.packages.${pkgs.system}.default ];
}
12 changes: 2 additions & 10 deletions nixosConfigurations/default.nix
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
{
inputs,
self,
nixpkgs,
nixosModules ? self.nixosModules,
disko ? inputs.disko,
...
}:
{ nixpkgs, ... }@args:
let
inherit (nixpkgs.lib) nixosSystem;

defaultArgs = {
specialArgs = {
make-disk-image = import "${nixpkgs}/nixos/lib/make-disk-image.nix";
inherit disko nixosModules;
};
} // args;
};

in
Expand Down

0 comments on commit 489416f

Please sign in to comment.