Skip to content

Commit

Permalink
instantiate pkgs only once (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
gvolpe authored Sep 16, 2023
1 parent d841b95 commit 3fbc4ae
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 94 deletions.
15 changes: 11 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
};

#sxm-flake = {
#url = git+file:///home/gvolpe/workspace/sxm/sxm-flake;
#url = git+file:///home/gvolpe/workspace/sxm/sxm-flake;
#};

neovim-flake = {
Expand Down Expand Up @@ -65,14 +65,21 @@
outputs = inputs:
let
system = "x86_64-linux";
ci = import ./outputs/ci.nix { inherit inputs system; };

pkgs = import inputs.nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = import ./lib/overlays.nix { inherit inputs system; };
};

ci = import ./outputs/ci.nix { inherit pkgs; };
in
{
homeConfigurations =
import ./outputs/home-conf.nix { inherit inputs system; };
import ./outputs/home-conf.nix { inherit inputs system pkgs; };

nixosConfigurations =
import ./outputs/nixos-conf.nix { inherit inputs system; };
import ./outputs/nixos-conf.nix { inherit inputs system pkgs; };

packages.${system} = {
inherit (ci) metals metals-updater;
Expand Down
42 changes: 42 additions & 0 deletions lib/overlays.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{ inputs, system }:

with inputs;

let
cowsayOverlay = f: p: {
inherit (inputs.cowsay.packages.${system}) cowsay;
};

fishOverlay = f: p: {
inherit fish-bobthefish-theme fish-keytool-completions;
};

nautilusOverlay = f: p: {
nautilus-gtk3 = nixpkgs-nautilus-gtk3.legacyPackages.${system}.gnome.nautilus;
};

libOverlay = f: p: rec {
libx = import ./. { inherit (p) lib; };
lib = p.lib.extend (_: _: {
inherit (libx) removeNewline secretManager;
});
};

sxmOverlay =
if (builtins.hasAttr "sxm-flake" inputs)
then sxm-flake.overlays.default
else (f: p: { });
in
[
cowsayOverlay
fishOverlay
libOverlay
nautilusOverlay
nurpkgs.overlay
neovim-flake.overlays.${system}.default
statix.overlays.default
sxmOverlay
(import ../home/overlays/bat-lvl)
(import ../home/overlays/nautilus)
(import ../home/overlays/ranger)
]
15 changes: 1 addition & 14 deletions outputs/ci.nix
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
{ inputs, system, ... }:
{ pkgs, ... }:

with inputs;

let
pkgs = import nixpkgs {
inherit system;

config.allowUnfree = true;

overlays = [
neovim-flake.overlays.${system}.default
];
};
in
{
metals = pkgs.callPackage ../home/programs/neovim-ide/metals.nix { };
metals-updater = pkgs.callPackage ../home/programs/neovim-ide/update-metals.nix { };
Expand Down
56 changes: 3 additions & 53 deletions outputs/home-conf.nix
Original file line number Diff line number Diff line change
@@ -1,57 +1,8 @@
{ inputs, system, ... }:
{ inputs, system, pkgs, ... }:

with inputs;

let
cowsayOverlay = f: p: {
inherit (inputs.cowsay.packages.${system}) cowsay;
};

fishOverlay = f: p: {
inherit fish-bobthefish-theme fish-keytool-completions;
};

nautilusOverlay = f: p: {
nautilus-gtk3 = nixpkgs-nautilus-gtk3.legacyPackages.${system}.gnome.nautilus;
};

libOverlay = f: p: rec {
libx = import ../lib { inherit (p) lib; };
lib = p.lib.extend (_: _: {
inherit (libx) removeNewline secretManager;
});
};

sxmOverlay =
if (builtins.hasAttr "sxm-flake" inputs)
then sxm-flake.overlays.default
else (f: p: { });

pkgs = import nixpkgs {
inherit system;

config.allowUnfree = true;

overlays = [
cowsayOverlay
fishOverlay
libOverlay
nautilusOverlay
nurpkgs.overlay
neovim-flake.overlays.${system}.default
statix.overlays.default
sxmOverlay
(import ../home/overlays/bat-lvl)
(import ../home/overlays/nautilus)
(import ../home/overlays/ranger)
];
};

nur = import nurpkgs {
inherit pkgs;
nurpkgs = pkgs;
};

imports = [
neovim-flake.nixosModules.${system}.hm
../home/home.nix
Expand All @@ -62,10 +13,9 @@ let
inherit pkgs;

extraSpecialArgs = {
inherit hidpi;
inherit (inputs) gh-md-toc;
inherit gh-md-toc hidpi;
inherit (rycee-nurpkgs.lib.${system}) buildFirefoxXpiAddon;
addons = nur.repos.rycee.firefox-addons;
addons = pkgs.nur.repos.rycee.firefox-addons;
};

modules = [{ inherit imports; }];
Expand Down
24 changes: 1 addition & 23 deletions outputs/nixos-conf.nix
Original file line number Diff line number Diff line change
@@ -1,29 +1,7 @@
{ inputs, system, ... }:
{ inputs, system, pkgs, lib ? pkgs.lib, ... }:

let
inherit (inputs.nixpkgs.lib) nixosSystem;

libx = import ../lib { inherit (inputs.nixpkgs) lib; };

lib = inputs.nixpkgs.lib.extend (_: _: {
inherit (libx) secretManager;
});

sxmOverlay =
if (builtins.hasAttr "sxm-flake" inputs)
then inputs.sxm-flake.overlays.default
else (f: p: { });

pkgs = import inputs.nixpkgs {
inherit system;
config = {
allowUnfree = true;
permittedInsecurePackages = [
"xrdp-0.9.9"
];
};
overlays = [ sxmOverlay ];
};
in
{
dell-xps = nixosSystem {
Expand Down

0 comments on commit 3fbc4ae

Please sign in to comment.