examples: add flake.nix to each example

This makes hte examples more standalone and suitable for copy & paste
This commit is contained in:
DavHau 2023-10-31 14:26:26 +03:00 committed by mergify[bot]
parent 61bc3b1377
commit 5914156eb7
30 changed files with 820 additions and 46 deletions

View File

@ -0,0 +1,32 @@
{
description = "My flake with dream2nix packages";
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
};
outputs = inputs @ {
self,
dream2nix,
nixpkgs,
...
}: let
system = "x86_64-linux";
in {
# All packages defined in ./packages/<name> are automatically added to the flake outputs
# e.g., 'packages/hello/default.nix' becomes '.#packages.hello'
packages.${system}.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
modules = [
./default.nix
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./.;
}
];
};
};
}

View File

@ -0,0 +1,32 @@
{
description = "My flake with dream2nix packages";
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
};
outputs = inputs @ {
self,
dream2nix,
nixpkgs,
...
}: let
system = "x86_64-linux";
in {
# All packages defined in ./packages/<name> are automatically added to the flake outputs
# e.g., 'packages/hello/default.nix' becomes '.#packages.hello'
packages.${system}.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
modules = [
./default.nix
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./.;
}
];
};
};
}

View File

@ -0,0 +1,32 @@
{
description = "My flake with dream2nix packages";
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
};
outputs = inputs @ {
self,
dream2nix,
nixpkgs,
...
}: let
system = "x86_64-linux";
in {
# All packages defined in ./packages/<name> are automatically added to the flake outputs
# e.g., 'packages/hello/default.nix' becomes '.#packages.hello'
packages.${system}.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
modules = [
./default.nix
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./.;
}
];
};
};
}

View File

@ -0,0 +1,32 @@
{
description = "My flake with dream2nix packages";
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
};
outputs = inputs @ {
self,
dream2nix,
nixpkgs,
...
}: let
system = "x86_64-linux";
in {
# All packages defined in ./packages/<name> are automatically added to the flake outputs
# e.g., 'packages/hello/default.nix' becomes '.#packages.hello'
packages.${system}.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
modules = [
./default.nix
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./.;
}
];
};
};
}

View File

@ -0,0 +1,32 @@
{
description = "My flake with dream2nix packages";
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
};
outputs = inputs @ {
self,
dream2nix,
nixpkgs,
...
}: let
system = "x86_64-linux";
in {
# All packages defined in ./packages/<name> are automatically added to the flake outputs
# e.g., 'packages/hello/default.nix' becomes '.#packages.hello'
packages.${system}.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
modules = [
./default.nix
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./.;
}
];
};
};
}

View File

@ -0,0 +1,32 @@
{
description = "My flake with dream2nix packages";
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
};
outputs = inputs @ {
self,
dream2nix,
nixpkgs,
...
}: let
system = "x86_64-linux";
in {
# All packages defined in ./packages/<name> are automatically added to the flake outputs
# e.g., 'packages/hello/default.nix' becomes '.#packages.hello'
packages.${system}.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
modules = [
./default.nix
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./.;
}
];
};
};
}

View File

@ -0,0 +1,32 @@
{
description = "My flake with dream2nix packages";
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
};
outputs = inputs @ {
self,
dream2nix,
nixpkgs,
...
}: let
system = "x86_64-linux";
in {
# All packages defined in ./packages/<name> are automatically added to the flake outputs
# e.g., 'packages/hello/default.nix' becomes '.#packages.hello'
packages.${system}.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
modules = [
./default.nix
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./.;
}
];
};
};
}

View File

@ -0,0 +1,32 @@
{
description = "My flake with dream2nix packages";
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
};
outputs = inputs @ {
self,
dream2nix,
nixpkgs,
...
}: let
system = "x86_64-linux";
in {
# All packages defined in ./packages/<name> are automatically added to the flake outputs
# e.g., 'packages/hello/default.nix' becomes '.#packages.hello'
packages.${system}.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
modules = [
./default.nix
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./.;
}
];
};
};
}

View File

@ -0,0 +1,32 @@
{
description = "My flake with dream2nix packages";
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
};
outputs = inputs @ {
self,
dream2nix,
nixpkgs,
...
}: let
system = "x86_64-linux";
in {
# All packages defined in ./packages/<name> are automatically added to the flake outputs
# e.g., 'packages/hello/default.nix' becomes '.#packages.hello'
packages.${system}.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
modules = [
./default.nix
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./.;
}
];
};
};
}

View File

@ -0,0 +1,32 @@
{
description = "My flake with dream2nix packages";
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
};
outputs = inputs @ {
self,
dream2nix,
nixpkgs,
...
}: let
system = "x86_64-linux";
in {
# All packages defined in ./packages/<name> are automatically added to the flake outputs
# e.g., 'packages/hello/default.nix' becomes '.#packages.hello'
packages.${system}.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
modules = [
./default.nix
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./.;
}
];
};
};
}

View File

@ -0,0 +1,32 @@
{
description = "My flake with dream2nix packages";
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
};
outputs = inputs @ {
self,
dream2nix,
nixpkgs,
...
}: let
system = "x86_64-linux";
in {
# All packages defined in ./packages/<name> are automatically added to the flake outputs
# e.g., 'packages/hello/default.nix' becomes '.#packages.hello'
packages.${system}.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
modules = [
./default.nix
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./.;
}
];
};
};
}

View File

@ -0,0 +1,32 @@
{
description = "My flake with dream2nix packages";
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
};
outputs = inputs @ {
self,
dream2nix,
nixpkgs,
...
}: let
system = "x86_64-linux";
in {
# All packages defined in ./packages/<name> are automatically added to the flake outputs
# e.g., 'packages/hello/default.nix' becomes '.#packages.hello'
packages.${system}.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
modules = [
./default.nix
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./.;
}
];
};
};
}

View File

@ -0,0 +1,32 @@
{
description = "My flake with dream2nix packages";
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
};
outputs = inputs @ {
self,
dream2nix,
nixpkgs,
...
}: let
system = "x86_64-linux";
in {
# All packages defined in ./packages/<name> are automatically added to the flake outputs
# e.g., 'packages/hello/default.nix' becomes '.#packages.hello'
packages.${system}.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
modules = [
./default.nix
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./.;
}
];
};
};
}

View File

@ -2,12 +2,12 @@
"fetchPipMetadata": {
"sources": {
"subpkg1": {
"path": "examples/packages/single-language/python-local-dependencies/subpkg1",
"path": "subpkg1",
"type": "local",
"version": "0.0.1"
},
"subpkg2": {
"path": "examples/packages/single-language/python-local-dependencies/subpkg2",
"path": "subpkg2",
"type": "local",
"version": "0.0.2"
}
@ -21,5 +21,5 @@
}
}
},
"invalidationHash": "226b1267f23fd3705dd88929c9eb630aececd273204130ad42f13a4f7b8e35ca"
}
"invalidationHash": "bc71d202ddaae6e0f6c82dd44fd81ed0c6971b9a18e84a24d633365be1ef30fb"
}

View File

@ -0,0 +1,32 @@
{
description = "My flake with dream2nix packages";
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
};
outputs = inputs @ {
self,
dream2nix,
nixpkgs,
...
}: let
system = "x86_64-linux";
in {
# All packages defined in ./packages/<name> are automatically added to the flake outputs
# e.g., 'packages/hello/default.nix' becomes '.#packages.hello'
packages.${system}.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
modules = [
./default.nix
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./.;
}
];
};
};
}

View File

@ -0,0 +1,32 @@
{
description = "My flake with dream2nix packages";
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
};
outputs = inputs @ {
self,
dream2nix,
nixpkgs,
...
}: let
system = "x86_64-linux";
in {
# All packages defined in ./packages/<name> are automatically added to the flake outputs
# e.g., 'packages/hello/default.nix' becomes '.#packages.hello'
packages.${system}.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
modules = [
./default.nix
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./.;
}
];
};
};
}

View File

@ -0,0 +1,32 @@
{
description = "My flake with dream2nix packages";
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
};
outputs = inputs @ {
self,
dream2nix,
nixpkgs,
...
}: let
system = "x86_64-linux";
in {
# All packages defined in ./packages/<name> are automatically added to the flake outputs
# e.g., 'packages/hello/default.nix' becomes '.#packages.hello'
packages.${system}.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
modules = [
./default.nix
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./.;
}
];
};
};
}

View File

@ -0,0 +1,32 @@
{
description = "My flake with dream2nix packages";
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
};
outputs = inputs @ {
self,
dream2nix,
nixpkgs,
...
}: let
system = "x86_64-linux";
in {
# All packages defined in ./packages/<name> are automatically added to the flake outputs
# e.g., 'packages/hello/default.nix' becomes '.#packages.hello'
packages.${system}.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
modules = [
./default.nix
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./.;
}
];
};
};
}

View File

@ -0,0 +1,32 @@
{
description = "My flake with dream2nix packages";
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
};
outputs = inputs @ {
self,
dream2nix,
nixpkgs,
...
}: let
system = "x86_64-linux";
in {
# All packages defined in ./packages/<name> are automatically added to the flake outputs
# e.g., 'packages/hello/default.nix' becomes '.#packages.hello'
packages.${system}.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
modules = [
./default.nix
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./.;
}
];
};
};
}

View File

@ -0,0 +1,32 @@
{
description = "My flake with dream2nix packages";
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
};
outputs = inputs @ {
self,
dream2nix,
nixpkgs,
...
}: let
system = "x86_64-linux";
in {
# All packages defined in ./packages/<name> are automatically added to the flake outputs
# e.g., 'packages/hello/default.nix' becomes '.#packages.hello'
packages.${system}.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
modules = [
./default.nix
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./.;
}
];
};
};
}

View File

@ -0,0 +1,32 @@
{
description = "My flake with dream2nix packages";
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
};
outputs = inputs @ {
self,
dream2nix,
nixpkgs,
...
}: let
system = "x86_64-linux";
in {
# All packages defined in ./packages/<name> are automatically added to the flake outputs
# e.g., 'packages/hello/default.nix' becomes '.#packages.hello'
packages.${system}.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
modules = [
./default.nix
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./.;
}
];
};
};
}

View File

@ -0,0 +1,32 @@
{
description = "My flake with dream2nix packages";
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
};
outputs = inputs @ {
self,
dream2nix,
nixpkgs,
...
}: let
system = "x86_64-linux";
in {
# All packages defined in ./packages/<name> are automatically added to the flake outputs
# e.g., 'packages/hello/default.nix' becomes '.#packages.hello'
packages.${system}.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
modules = [
./default.nix
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./.;
}
];
};
};
}

View File

@ -0,0 +1,32 @@
{
description = "My flake with dream2nix packages";
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
};
outputs = inputs @ {
self,
dream2nix,
nixpkgs,
...
}: let
system = "x86_64-linux";
in {
# All packages defined in ./packages/<name> are automatically added to the flake outputs
# e.g., 'packages/hello/default.nix' becomes '.#packages.hello'
packages.${system}.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
modules = [
./default.nix
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./.;
}
];
};
};
}

View File

@ -0,0 +1,32 @@
{
description = "My flake with dream2nix packages";
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
};
outputs = inputs @ {
self,
dream2nix,
nixpkgs,
...
}: let
system = "x86_64-linux";
in {
# All packages defined in ./packages/<name> are automatically added to the flake outputs
# e.g., 'packages/hello/default.nix' becomes '.#packages.hello'
packages.${system}.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
modules = [
./default.nix
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./.;
}
];
};
};
}

View File

@ -30,7 +30,7 @@ in {
path = toString path';
in
if path == projectRoot
then "./."
then "."
else if lib.hasPrefix projectRoot path
then lib.path.subpath.normalise "./${lib.removePrefix projectRoot path}"
else lib.path.subpath.normalise "./${path}";

View File

@ -26,8 +26,8 @@
in
flip mapAttrs examples
(name: _: {
module = examplesPath + "/${name}";
packagePath = "/examples/packages/${dirName}/${name}";
dir = examplesPath + "/${name}";
flake = examplesPath + "/${name}/flake.nix";
});
importFlake = flakeFile: let
@ -51,14 +51,19 @@
modulesFlake = import (self + /modules) {};
# Type: [ {${name} = {module, packagePath} ]
allExamples = mapAttrsToList (dirName: _: readExamples dirName) packageCategories;
allExamplesList = mapAttrsToList (dirName: _: readExamples dirName) packageCategories;
exampleModules = foldl (a: b: a // b) {} allExamples;
exampleFlakes = foldl (a: b: a // b) {} allExamplesList;
# create a template for each example package
packageTempaltes = flip mapAttrs exampleModules (name: def: {
packageTempaltes = flip mapAttrs exampleFlakes (name: def: {
description = "Example package ${name}";
path = def.module;
path = def.dir;
});
allExamples = flip mapAttrs' exampleFlakes (name: example: {
name = "example-package-${name}";
value = example.flake;
});
in {
flake.templates =
@ -77,48 +82,18 @@ in {
pkgs,
...
}: let
# A module imported into every package setting up the eval cache
setup = {config, ...}: {
paths.projectRoot = self;
eval-cache.enable = true;
deps.npm = inputs.nixpkgs.legacyPackages.${system}.nodejs.pkgs.npm.override (old: rec {
version = "8.19.4";
src = builtins.fetchTarball {
url = "https://registry.npmjs.org/npm/-/npm-${version}.tgz";
sha256 = "0xmvjkxgfavlbm8cj3jx66mlmc20f9kqzigjqripgj71j6b2m9by";
};
});
};
# evaluates the package behind a given module
makeDrv = modules: let
evaled = self.lib.evalModules {
modules = modules ++ [self.modules.dream2nix.core];
packageSets = {
nixpkgs = inputs.nixpkgs.legacyPackages.${system};
writers = config.writers;
};
};
getPackage = flakeFile: let
flake = importFlake flakeFile;
in
evaled.config.public;
allModules = flip mapAttrs' exampleModules (name: module: {
name = "example-package-${name}";
value = [
module.module
setup
{
paths.package = module.packagePath;
}
];
});
flake.packages.${system}.default;
# map all modules in /examples to a package output in the flake.
checks =
lib.optionalAttrs
(system == "x86_64-linux")
(
(lib.mapAttrs (_: drvModules: makeDrv drvModules) allModules)
(lib.mapAttrs (_: flakeFile: getPackage flakeFile) allExamples)
// {
example-repo =
(import (self + /examples/repo) {

View File

@ -17,6 +17,26 @@
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1698579227,
"narHash": "sha256-KVWjFZky+gRuWennKsbo6cWyo7c/z/VgCte5pR9pEKg=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "f76e870d64779109e41370848074ac4eaa1606ec",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1695837737,
@ -73,6 +93,7 @@
"root": {
"inputs": {
"flake-compat": "flake-compat",
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs",
"purescript-overlay": "purescript-overlay",
"pyproject-nix": "pyproject-nix"

32
scripts/flake.nix Normal file
View File

@ -0,0 +1,32 @@
{
description = "My flake with dream2nix packages";
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
};
outputs = inputs @ {
self,
dream2nix,
nixpkgs,
...
}: let
system = "x86_64-linux";
in {
# All packages defined in ./packages/<name> are automatically added to the flake outputs
# e.g., 'packages/hello/default.nix' becomes '.#packages.hello'
packages.${system}.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
modules = [
./default.nix
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./.;
}
];
};
};
}

10
scripts/update-examples.sh Executable file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env bash
# find script directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# find examples directory
packagesDir="$DIR/../examples/packages"
# iterate over all double nested package directories and copy the flake file there
echo "$packagesDir"/*/*/ | xargs -n 1 cp "$DIR"/flake.nix

View File

@ -25,7 +25,7 @@ in {
expr = {inherit (config.paths) projectRoot package;};
expected = {
projectRoot = "${./.}";
package = "./.";
package = ".";
};
};