mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-11-26 22:31:39 +03:00
Merge pull request #609 from nix-community/docs
examples: move to /examples from /modules/drvs
This commit is contained in:
commit
8f36c5b85e
@ -1,14 +1,15 @@
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
dream2nix,
|
||||
...
|
||||
}: let
|
||||
l = lib // builtins;
|
||||
system = config.deps.stdenv.system;
|
||||
in {
|
||||
imports = [
|
||||
../../drv-parts/nodejs-package-json
|
||||
../../drv-parts/nodejs-granular
|
||||
dream2nix.modules.drv-parts.nodejs-package-json
|
||||
dream2nix.modules.drv-parts.nodejs-granular
|
||||
];
|
||||
|
||||
mkDerivation = {
|
||||
@ -42,5 +43,5 @@ in {
|
||||
version = l.mkForce "0.0.0";
|
||||
|
||||
lock.lockFileRel =
|
||||
l.mkForce "/modules/drvs/nodejs-no-lock/lock-${system}.json";
|
||||
l.mkForce "/locks/example-package-nodejs-no-lock/lock-${system}.json";
|
||||
}
|
@ -1,12 +1,13 @@
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
dream2nix,
|
||||
...
|
||||
}: let
|
||||
l = lib // builtins;
|
||||
in {
|
||||
imports = [
|
||||
../../drv-parts/nodejs-devshell
|
||||
dream2nix.modules.drv-parts.nodejs-devshell
|
||||
];
|
||||
|
||||
mkDerivation = {
|
@ -1,12 +1,13 @@
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
dream2nix,
|
||||
...
|
||||
}: let
|
||||
l = lib // builtins;
|
||||
in {
|
||||
imports = [
|
||||
../../drv-parts/nodejs-node-modules
|
||||
dream2nix.modules.drv-parts.nodejs-node-modules
|
||||
];
|
||||
|
||||
mkDerivation = {
|
@ -1,13 +1,14 @@
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
dream2nix,
|
||||
...
|
||||
}: let
|
||||
l = lib // builtins;
|
||||
in {
|
||||
imports = [
|
||||
../../drv-parts/nodejs-package-lock
|
||||
../../drv-parts/nodejs-granular
|
||||
dream2nix.modules.drv-parts.nodejs-package-lock
|
||||
dream2nix.modules.drv-parts.nodejs-granular
|
||||
];
|
||||
|
||||
mkDerivation = {
|
@ -1,12 +1,13 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
dream2nix,
|
||||
...
|
||||
}: let
|
||||
l = lib // builtins;
|
||||
in {
|
||||
imports = [
|
||||
../../drv-parts/pip
|
||||
dream2nix.modules.drv-parts.pip
|
||||
];
|
||||
|
||||
deps = {nixpkgs, ...}: {
|
@ -1,13 +1,14 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
dream2nix,
|
||||
...
|
||||
}: let
|
||||
l = lib // builtins;
|
||||
python = config.deps.python;
|
||||
in {
|
||||
imports = [
|
||||
../../drv-parts/pip
|
||||
dream2nix.modules.drv-parts.pip
|
||||
];
|
||||
|
||||
deps = {
|
@ -7,14 +7,15 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
dream2nix,
|
||||
...
|
||||
}: let
|
||||
l = lib // builtins;
|
||||
in {
|
||||
imports = [
|
||||
../../drv-parts/nodejs-package-lock
|
||||
../../drv-parts/nodejs-granular
|
||||
../../drv-parts/pip
|
||||
dream2nix.modules.drv-parts.nodejs-package-lock
|
||||
dream2nix.modules.drv-parts.nodejs-granular
|
||||
dream2nix.modules.drv-parts.pip
|
||||
];
|
||||
|
||||
name = "isso";
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
dream2nix,
|
||||
...
|
||||
}: let
|
||||
l = lib // builtins;
|
||||
@ -14,7 +15,7 @@
|
||||
};
|
||||
in {
|
||||
imports = [
|
||||
../../drv-parts/pip
|
||||
dream2nix.modules.drv-parts.pip
|
||||
];
|
||||
|
||||
deps = {nixpkgs, ...}: {
|
@ -3,12 +3,13 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
dream2nix,
|
||||
...
|
||||
}: let
|
||||
l = lib // builtins;
|
||||
in {
|
||||
imports = [
|
||||
../../drv-parts/pip
|
||||
dream2nix.modules.drv-parts.pip
|
||||
];
|
||||
|
||||
deps = {nixpkgs, ...}: {
|
@ -13,20 +13,22 @@
|
||||
}: let
|
||||
inherit
|
||||
(lib)
|
||||
mapAttrs'
|
||||
filterAttrs
|
||||
flip
|
||||
foldl
|
||||
hasPrefix
|
||||
mapAttrs'
|
||||
mapAttrsToList
|
||||
removePrefix
|
||||
;
|
||||
inherit
|
||||
(builtins)
|
||||
mapAttrs
|
||||
readDir
|
||||
;
|
||||
|
||||
# A module imported into every package setting up the eval cache
|
||||
setup = {config, ...}: {
|
||||
lock.lockFileRel = "/modules/drvs/${config.name}/lock-${system}.json";
|
||||
lock.repoRoot = self;
|
||||
eval-cache.cacheFileRel = "/modules/drvs/${config.name}/cache-${system}.json";
|
||||
eval-cache.repoRoot = self;
|
||||
eval-cache.enable = true;
|
||||
deps.npm = inputs.nixpkgs.legacyPackages.${system}.nodejs.pkgs.npm.override (old: rec {
|
||||
@ -39,13 +41,9 @@
|
||||
};
|
||||
|
||||
# evaluates the package behind a given module
|
||||
makeDrv = module: let
|
||||
makeDrv = modules: let
|
||||
evaled = lib.evalModules {
|
||||
modules = [
|
||||
self.modules.drv-parts.core
|
||||
module
|
||||
setup
|
||||
];
|
||||
modules = modules ++ [self.modules.drv-parts.core];
|
||||
specialArgs.packageSets = {
|
||||
nixpkgs = inputs.nixpkgs.legacyPackages.${system};
|
||||
writers = config.writers;
|
||||
@ -55,22 +53,44 @@
|
||||
in
|
||||
evaled.config.public;
|
||||
|
||||
examples = readDir (self + /examples/dream2nix-packages);
|
||||
examplePackagesDirs =
|
||||
filterAttrs
|
||||
(name: _: hasPrefix "dream2nix-packages" name)
|
||||
(readDir (self + "/examples"));
|
||||
|
||||
exampleModules =
|
||||
flip mapAttrs examples
|
||||
(name: _: self + /examples/dream2nix-packages + "/${name}");
|
||||
readExamples = dirName: let
|
||||
prefix = removePrefix "dream2nix-packages-" dirName;
|
||||
examplesPath = self + /examples + "/${dirName}";
|
||||
examples = readDir examplesPath;
|
||||
in
|
||||
flip mapAttrs' examples
|
||||
(name: _: {
|
||||
name = "example-package-${prefix}-${name}";
|
||||
value = examplesPath + "/${name}";
|
||||
});
|
||||
|
||||
allModules' = self.modules.drvs // exampleModules;
|
||||
allExamples = mapAttrsToList (dirName: _: readExamples dirName) examplePackagesDirs;
|
||||
|
||||
exampleModules = foldl (a: b: a // b) {} allExamples;
|
||||
|
||||
# TODO: remove this line once everything is migrated to the new structure
|
||||
allModules' = self.modules.drvs or {} // exampleModules;
|
||||
|
||||
allModules = flip mapAttrs' allModules' (name: module: {
|
||||
name = "example-package-${name}";
|
||||
value = module;
|
||||
inherit name;
|
||||
value = [
|
||||
module
|
||||
setup
|
||||
{
|
||||
lock.lockFileRel = "/locks/${name}/lock-${system}.json";
|
||||
eval-cache.cacheFileRel = "/locks/${name}/cache-${system}.json";
|
||||
}
|
||||
];
|
||||
});
|
||||
in {
|
||||
# map all modules in ../drvs to a package output in the flake.
|
||||
# map all modules in /examples to a package output in the flake.
|
||||
checks =
|
||||
lib.mapAttrs (_: drvModule: makeDrv drvModule)
|
||||
lib.mapAttrs (_: drvModules: makeDrv drvModules)
|
||||
allModules;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user