dumb-manager lol

pci.express bc85bfa6 930d7824

verified
+12 -2
flake.nix
···
}
)
);
+
dumb-manager = import ./lib/dumb-manager.nix;
in
{
nixosConfigurations = {
···
};
};
packages = forAllSystems (pkgs: {
-
# Too lazy to do callPackage...
-
mac-home = (import ./home/mac) pkgs;
+
# mac-home = (import ./home/mac) {inherit pkgs;};
+
mac-home = dumb-manager.configuration {
+
inherit pkgs nixpkgs;
+
module = ./home/mac;
+
};
});
+
# apps = forAllSystems (pkgs: {
+
# update-links = {
+
# type = "app";
+
# program = "${self.packages.${pkgs.system}.update-links}";
+
# };
+
# });
formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
};
}
+5 -5
home/mac/default.nix
···
-
pkgs:
-
-
pkgs.buildEnv {
-
name = "mac-home";
-
paths = with pkgs; [
+
{ pkgs }:
+
{
+
username = "user";
+
homeDirectory = "/Users/user";
+
packages = with pkgs; [
zig
flashrom
tree
+20
lib/dumb-manager.nix
···
+
{
+
configuration =
+
{
+
pkgs,
+
nixpkgs,
+
module,
+
}:
+
let
+
cfg = (import module) { inherit pkgs; };
+
inherit (cfg) homeDirectory;
+
update-links = import ./update-links.nix;
+
packages = (cfg.packages or [ ]) ++ [
+
(update-links { inherit pkgs nixpkgs homeDirectory; })
+
];
+
in
+
pkgs.buildEnv {
+
name = "dumb-manager";
+
paths = packages;
+
};
+
}
+33
lib/update-links.nix
···
+
{
+
nixpkgs,
+
pkgs,
+
homeDirectory,
+
}:
+
let
+
registry = {
+
flakes = [
+
{
+
exact = true;
+
from = {
+
id = "n";
+
type = "indirect";
+
};
+
to = {
+
path = "${nixpkgs}";
+
type = "path";
+
};
+
}
+
];
+
version = 2;
+
};
+
registryFile = pkgs.writeTextFile {
+
name = "registry.json";
+
destination = "/.config/nix/registry.json";
+
text = builtins.toJSON registry;
+
};
+
in
+
pkgs.writeShellScriptBin "update-links" ''
+
#!/usr/bin/env bash
+
mkdir -p ${homeDirectory}/.config/nix
+
ln -sf ${registryFile}/.config/nix/registry.json ${homeDirectory}/.config/nix/registry.json
+
''