Simplifications

This commit is contained in:
Daniel Winkler 2025-09-12 12:45:05 +10:00
commit 4aa8ae44f8

View file

@ -20,25 +20,17 @@
"x86_64-darwin" "x86_64-darwin"
"aarch64-darwin" "aarch64-darwin"
]; ];
forAllSystems = f: forAllSystems = nixpkgs.lib.genAttrs systems;
builtins.listToAttrs (map (system: {
name = system;
value = f system;
})
systems);
# The overlay that exposes custom R packages # The overlay that exposes custom R packages
overlay = final: prev: let overlay = final: prev: {
readJSONFile = path: builtins.fromJSON (builtins.readFile path); extraRPackages = let
fetchfromGitHubJSONFile = path: prev.fetchFromGitHub (builtins.fromJSON (builtins.readFile path));
in { in {
extraRPackages = {
## H ## H
httpgd = let httpgd = prev.rPackages.buildRPackage {
httpgdLatest = readJSONFile ./versions/httpgd.json;
in
prev.rPackages.buildRPackage {
name = "httpgd"; name = "httpgd";
src = prev.fetchFromGitHub httpgdLatest; src = fetchfromGitHubJSONFile ./versions/httpgd.json;
propagatedBuildInputs = builtins.attrValues { propagatedBuildInputs = builtins.attrValues {
inherit inherit
(prev.rPackages) (prev.rPackages)
@ -50,12 +42,9 @@
}; };
## M ## M
musicMetadata = let musicMetadata = prev.rPackages.buildRPackage {
musicMetadataLatest = readJSONFile ./versions/musicMetadata.json;
in
prev.rPackages.buildRPackage {
name = "musicMetadata"; name = "musicMetadata";
src = prev.fetchFromGitHub musicMetadataLatest; src = fetchfromGitHubJSONFile ./versions/musicMetadata.json;
}; };
## N ## N
@ -71,20 +60,18 @@
}; };
## S ## S
synthdid = let synthdid = prev.rPackages.buildRPackage {
synthdidLatest = readJSONFile ./versions/synthdid.json;
in
prev.rPackages.buildRPackage {
name = "synthdid"; name = "synthdid";
src = prev.fetchFromGitHub synthdidLatest; src = fetchfromGitHubJSONFile ./versions/synthdid.json;
propagatedBuildInputs = [prev.rPackages.mvtnorm]; propagatedBuildInputs = [prev.rPackages.mvtnorm];
}; };
}; };
}; };
in { in {
# For imports in other flakes
overlays.default = overlay; overlays.default = overlay;
# Optional: provide an R wrapper with these non-CRAN packages bundled # run these with `nix run .#NAME`
packages = forAllSystems ( packages = forAllSystems (
system: let system: let
pkgs = import nixpkgs { pkgs = import nixpkgs {
@ -96,8 +83,9 @@
franUpdate = pkgs.writeShellScriptBin "fran-update" (import ./versions pkgs); franUpdate = pkgs.writeShellScriptBin "fran-update" (import ./versions pkgs);
} }
); );
# Helpful for overlay users: expose a devShell with R including these pkgs # Run this with `nix develop`
devShells = forAllSystems (system: let devShells = forAllSystems (
system: let
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
overlays = [self.overlays.default]; overlays = [self.overlays.default];
@ -109,7 +97,8 @@
franUpdate franUpdate
]; ];
}; };
}); }
);
}; };
nixConfig = { nixConfig = {
extra-substituters = [ extra-substituters = [