Skip to content

Commit

Permalink
Add packages & refactor flake.nix
Browse files Browse the repository at this point in the history
  • Loading branch information
bryango committed Feb 22, 2024
1 parent c37aa31 commit ebb93ca
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 65 deletions.
8 changes: 4 additions & 4 deletions flake.lock

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

52 changes: 19 additions & 33 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
let

## consistent namings
cheznix = self;
nixpkgs-follows =
let
result = "nixpkgs-config";
Expand All @@ -44,52 +43,42 @@
/* ^ refers to both the input _name_ & its _source_,
.. therefore these two must coincide! */

cheznix = self;
nixpkgs = self.inputs.${nixpkgs-follows};
inherit (nixpkgs) lib;

## upstream overrides: inputs.${nixpkgs-follows}
## home overlay:
overlay = final: prev: import ./overlay.nix final prev // {
overlay = final: prev: import ./overlay.nix final prev // (with final; {
inherit cheznix;
inherit (system-manager.packages.${prev.system}) system-manager;
};

nixpkgs = self.inputs.${nixpkgs-follows};
lib = nixpkgs.lib;
inherit (lib.chezlib) forMySystems;
pkgsOverlay = system: nixpkgs.legacyPackages.${system}.extend overlay;
inherit (system-manager.packages.${system}) system-manager;
});

machines = home-attrs.outputs;
forMyMachines = f: lib.mapAttrs' f machines;
inherit (lib)
mySystems
forMySystems;

mkSystemPkgs = system: nixpkgs.legacyPackages.${system}.extend overlay;

updateHomeAttrs = id: profile:
profile // {
hostname = profile.hostname or id;
pkgs = pkgsOverlay profile.system;
pkgs =
assert lib.elem profile.system mySystems;
mkSystemPkgs profile.system;
};

mkHomeConfig = id: profile:
let
attrs = updateHomeAttrs id profile;
inherit (attrs) pkgs;

home-manager =
let
## retrieve the unfixed flake outputs
unfixed = (
## force an import from derivation (IFD)
import "${pkgs.home-manager.src}/flake.nix"
).outputs;

## find the fixed point manually
fixed-point = unfixed {
self = fixed-point;
inherit nixpkgs;
};
in
fixed-point;
home-manager = attrs.pkgs.home-manager.flake;
in
{
name = "${attrs.username}@${attrs.hostname}";
value = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
inherit (attrs) pkgs;

## specify your home configuration modules
modules = [ ./home.nix ];
Expand Down Expand Up @@ -124,12 +113,9 @@
inherit lib;
homeConfigurations = forMyMachines mkHomeConfig;
systemConfigs = forMyMachines mkSystemConfig;
legacyPackages = forMySystems pkgsOverlay;
legacyPackages = forMySystems mkSystemPkgs;
packages = forMySystems (system: {
## passed from nixpkgs
inherit (self.legacyPackages.${system}) home-manager;
## `home-manager` as the default
default = self.packages.${system}.home-manager;
default = self.legacyPackages.${system}.home-manager;
});
overlays.default = overlay;
};
Expand Down
2 changes: 2 additions & 0 deletions home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ let
nixpkgs-fmt # the semi official formatter
nurl # generate fetcher call
nix-init # generate package
nix-update
nix-output-monitor
nixpkgs-hammering
nixpkgs-review
Expand Down Expand Up @@ -57,6 +58,7 @@ let
lsof
wget
trash-cli
git-branchless
openssh # need to unset SSH_AUTH_SOCK, maybe
# trashy # better, but its zsh completion is broken

Expand Down
2 changes: 1 addition & 1 deletion nixpkgs-config
32 changes: 5 additions & 27 deletions profile.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,9 @@
"outputs": null,
"priority": 5,
"storePaths": [
"/nix/store/q9q7biwfvpsxd86fy4b0krzr5mysz1lb-hydra-check-1.3.5"
"/nix/store/zplc7r9qkmz80fvhj4lgfifxr7wxkcq9-hydra-check-1.3.5"
],
"url": "git+file:///home/bryan/apps/nixpkgs/hydra-check?ref=refs/heads/bump-python-nixpkgs&rev=775d5897dc0f95ba3b817c5ade7fa8598d976d66"
},
{
"active": true,
"attrPath": "legacyPackages.x86_64-linux.nix-update",
"originalUrl": "flake:nixpkgs",
"outputs": null,
"priority": 5,
"storePaths": [
"/nix/store/yq22dg22s0f21jfqzi26937z96w749pr-nix-update-1.0.0"
],
"url": "github:NixOS/nixpkgs/0dc186716d75fcea44ec5ae33d6a9540015072a3"
},
{
"active": true,
"attrPath": "legacyPackages.x86_64-linux.git-branchless",
"originalUrl": "git+file:///home/bryan/.config/home-manager/nixpkgs-config",
"outputs": null,
"priority": 5,
"storePaths": [
"/nix/store/za8nqjbij9pfpvydp2hcypvh8fgsjl40-git-branchless-0.8.0"
],
"url": "git+file:///home/bryan/.config/home-manager/nixpkgs-config?ref=refs/heads/master&rev=7bd40a030e03909cdfd0ed69791a15d467d341cc"
"url": "git+file:///home/bryan/apps/nixpkgs/hydra-check?ref=refs/heads/master&rev=049b7a236cdee41bcf4905aa04c66c7e7085cbd8"
},
{
"active": true,
Expand All @@ -51,15 +29,15 @@
"outputs": null,
"priority": 5,
"storePaths": [
"/nix/store/2hishsjivlb1ibmqqbq6x599sqjw5mhv-wifipem-live-capture"
"/nix/store/54gc1xdzfmm1gc0ca5157a3p29g7xvhs-wifipem-live-capture"
],
"url": "git+file:///home/bryan/apps/dev/wifipem?ref=refs/heads/minimal&rev=97fbe4dee5e934e1b7c80deac572230fe66c2813"
"url": "git+file:///home/bryan/apps/dev/wifipem?ref=refs/heads/minimal&rev=1d79d55caebf7b1a05153f317a01b346c10affd3"
},
{
"active": true,
"priority": 5,
"storePaths": [
"/nix/store/j09285kmx0fniifjvk7szf7vylrlmpbv-home-manager-path"
"/nix/store/n27prlnwqc7b8hllrwx8ffa10pys2lhf-home-manager-path"
]
}
],
Expand Down

0 comments on commit ebb93ca

Please sign in to comment.