mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-09-11 14:35:30 +03:00
Merge pull request #341 from nix-community/devShell-example
Dev shell example
This commit is contained in:
commit
2b7456e3d2
46
examples/_d2n-extend-devShell/flake.nix
Normal file
46
examples/_d2n-extend-devShell/flake.nix
Normal 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;
|
||||
}
|
||||
];
|
||||
}
|
@ -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,
|
||||
|
@ -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}"));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user