Skip to content

Commit

Permalink
Pack and share stable, unstable and nur as overlays (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdalpra authored Mar 2, 2024
1 parent bea2dae commit 6c37b42
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 35 deletions.
11 changes: 6 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,28 @@
mkNixOS = import ./lib/mk-nixos.nix;
mkHM = import ./lib/mk-hm.nix;
mkDevShell = import ./lib/dev-shell.nix;
inherit (nixpkgs) lib;
overlays = import ./lib/overlays.nix { inherit nixpkgs nixpkgs-unstable nurpkgs; };
system = "x86_64-linux";
revision = nixpkgs.lib.mkIf (self ? rev) self.rev;
forAllSystems = flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
unstable = nixpkgs-unstable.legacyPackages.${system};
pkgs = overlays system;
agenixBin = agenix.packages.${system}.default;
in
{
formatter = pkgs.nixpkgs-fmt;
devShell = mkDevShell { inherit pkgs unstable agenixBin; };
devShell = mkDevShell { inherit pkgs agenixBin; };
});
in
nixpkgs.lib.recursiveUpdate forAllSystems {
packages.${system}.disko = disko.packages.${system}.default;
nixosConfigurations = {
iso = mkISO { inherit nixpkgs system; };
vm = mkNixOS "vm" { inherit nixpkgs home-manager disko system revision; };
vm = mkNixOS "vm" { inherit overlays lib home-manager disko system revision; };
};
homeConfigurations = {
pdalpra = mkHM "pdalpra" { inherit nixpkgs nixpkgs-unstable nurpkgs home-manager system; };
pdalpra = mkHM "pdalpra" { inherit overlays home-manager system; };
};
};
}
2 changes: 1 addition & 1 deletion lib/dev-shell.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, unstable, agenixBin }:
{ pkgs, agenixBin }:

with pkgs;

Expand Down
26 changes: 4 additions & 22 deletions lib/mk-hm.nix
Original file line number Diff line number Diff line change
@@ -1,31 +1,13 @@
username: { nixpkgs, nixpkgs-unstable, nurpkgs, home-manager, system }:
username: { overlays, home-manager, system }:

let
isDarwin = nixpkgs.lib.strings.hasSuffix system "-darwin";
pkgs = overlays system;
isDarwin = pkgs.lib.strings.hasSuffix system "-darwin";
specialArgs = {
inherit isDarwin;
myLib = import ./utils.nix { inherit (nixpkgs) lib; };
myLib = import ./utils.nix { inherit (pkgs) lib; };
};
config = { allowUnfree = true; };
homeDirectory = if isDarwin then "/Users/${username}" else "/home/${username}";
pkgsForNur = import nixpkgs { inherit config system; };
nurOverlay = final: prev: {
nur = import nurpkgs {
pkgs = pkgsForNur;
nurpkgs = pkgsForNur;
};
};
unstableOverlay = final: prev: {
unstable = import nixpkgs-unstable { inherit config system; };
};
pkgs = import nixpkgs {
inherit config system;

overlays = [
nurOverlay
unstableOverlay
];
};
in
home-manager.lib.homeManagerConfiguration {
inherit pkgs;
Expand Down
10 changes: 5 additions & 5 deletions lib/mk-nixos.nix
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
name: { nixpkgs, home-manager, disko, system, revision }:
name: { overlays, lib, home-manager, disko, system, revision }:

let
pkgs = overlays system;
specialArgs = {
hmPkgs = home-manager.packages.${system};
myLib = import ./utils.nix { inherit (nixpkgs) lib; };
myLib = import ./utils.nix { inherit (pkgs) lib; };
};
baseConfig = _: {
system.configurationRevision = revision;
networking.hostName = name;
nix.registry.nixpkgs.flake = nixpkgs;
};
machineRoot = ../system/machines + "/${name}";
specificConfig = machineRoot + /configuration.nix;
diskoConfig = import (machineRoot + /disks.nix) { };
in
nixpkgs.lib.nixosSystem {
inherit system specialArgs;
lib.nixosSystem {
inherit system specialArgs pkgs;

modules = [
baseConfig
Expand Down
23 changes: 23 additions & 0 deletions lib/overlays.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{ nixpkgs, nixpkgs-unstable, nurpkgs }: system:

let
config = { allowUnfree = true; };
pkgs = import nixpkgs { inherit config system; };
nurOverlay = final: prev: {
nur = import nurpkgs {
inherit pkgs;
nurpkgs = pkgs;
};
};
unstableOverlay = final: prev: {
unstable = import nixpkgs-unstable { inherit config system; };
};
in
import nixpkgs {
inherit config system;

overlays = [
nurOverlay
unstableOverlay
];
}
2 changes: 0 additions & 2 deletions system/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,5 @@ _:
};
};

nixpkgs.config.allowUnfree = true;

system.stateVersion = "22.11";
}

0 comments on commit 6c37b42

Please sign in to comment.