Merge pull request #341 from nix-community/devShell-example

Dev shell example
This commit is contained in:
DavHau 2022-10-28 23:46:27 +02:00 committed by GitHub
commit 2b7456e3d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 59 additions and 10 deletions

View File

@ -0,0 +1,46 @@
{
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
src.url = "github:prettier/prettier/2.4.1";
src.flake = false;
};
outputs = {
self,
dream2nix,
src,
} @ inp: let
nixpkgs = dream2nix.inputs.nixpkgs;
l = nixpkgs.lib // builtins;
systems = ["x86_64-linux"];
forAllSystems = f:
l.genAttrs systems (
system:
f system (nixpkgs.legacyPackages.${system})
);
d2n-flake = dream2nix.lib.makeFlakeOutputs {
inherit systems;
config.projectRoot = ./.;
source = src;
};
in
dream2nix.lib.dlib.mergeFlakes [
d2n-flake
{
devShells = forAllSystems (system: pkgs: {
prettier = d2n-flake.devShells.${system}.prettier.overrideAttrs (old: {
buildInputs =
old.buildInputs
++ [
pkgs.hello
];
});
});
}
{
checks.x86_64-linux.prettier = self.packages.x86_64-linux.prettier;
}
];
}

View File

@ -609,17 +609,8 @@ in let
};
projectOutputs = l.map outputsForProject translatedProjects;
mergedOutputs = let
isNotDrvAttrs = val:
l.isAttrs val && (val.type or "") != "derivation";
recursiveUpdateUntilDrv =
l.recursiveUpdateUntil
(_: l: r: !(isNotDrvAttrs l && isNotDrvAttrs r));
in
l.foldl' recursiveUpdateUntilDrv {} projectOutputs;
in
mergedOutputs;
dlib.mergeFlakes projectOutputs;
generateImpureResolveScript = {
source,

View File

@ -16,10 +16,12 @@
latestVersion
listDirs
listFiles
mergeFlakes
nameVersionPair
prepareSourceTree
readTextFile
recursiveUpdateUntilDepth
recursiveUpdateUntilDrv
simpleTranslate2
sanitizePath
sanitizeRelativePath
@ -243,6 +245,10 @@
# directory names of a given directory
dirNames = dir: l.attrNames (l.filterAttrs (name: type: type == "directory") (builtins.readDir dir));
# ensures that value is attrset but not a derivation
isNotDrvAttrs = val:
l.isAttrs val && (val.type or "") != "derivation";
# picks the latest version from a list of version strings
latestVersion = versions:
l.head
@ -252,6 +258,8 @@
listFiles = path: l.attrNames (l.filterAttrs (n: v: v == "regular") (builtins.readDir path));
mergeFlakes = flakes: l.foldl' recursiveUpdateUntilDrv {} flakes;
nameVersionPair = name: version: {inherit name version;};
prepareSourceTree = {
@ -266,6 +274,10 @@
recursiveUpdateUntilDepth = depth: lhs: rhs:
lib.recursiveUpdateUntil (path: _: _: (l.length path) > depth) lhs rhs;
recursiveUpdateUntilDrv =
l.recursiveUpdateUntil
(_: l: r: !(isNotDrvAttrs l && isNotDrvAttrs r));
sanitizeRelativePath = path:
l.removePrefix "/" (l.toString (l.toPath "/${path}"));