-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* flake.nix: Add flakeModule The flakeModule attribute allows the project to be integrated easily into flakes based on flake-parts, which is a minimal set of module system options that unifies many flake integrations. * Move template -> template/flake-utils * Add templates.flake-parts * DRY welcomeText --------- Co-authored-by: GuangTao Zhang <[email protected]>
- Loading branch information
Showing
6 changed files
with
130 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
top @ { | ||
config, | ||
flake-parts-lib, | ||
lib, | ||
... | ||
}: let | ||
inherit (lib) mkOption types; | ||
in { | ||
# User options defined in perSystem below. | ||
options.jupyenv.flake = mkOption { | ||
internal = true; | ||
description = "The jupyenv flake"; | ||
}; | ||
|
||
options.perSystem = flake-parts-lib.mkPerSystemOption ( | ||
{ | ||
config, | ||
pkgs, | ||
system, | ||
... | ||
}: let | ||
jupyenv = top.config.jupyenv.flake; | ||
cfg = config.jupyenv; | ||
inherit (jupyenv.lib.${system}) mkJupyterlabNew; | ||
|
||
jupyterlab = mkJupyterlabNew ({...}: { | ||
nixpkgs = pkgs; | ||
imports = [cfg.kernels]; | ||
}); | ||
in { | ||
options.jupyenv = { | ||
kernels = mkOption { | ||
type = types.deferredModule; | ||
description = '' | ||
A module that defines all the kernels to be installed. | ||
You may reference a file, or multiple files using `imports`. | ||
''; | ||
}; | ||
pkgs = mkOption { | ||
type = types.pkgs; | ||
description = '' | ||
Nixpkgs instance to use. | ||
''; | ||
default = pkgs; | ||
defaultText = lib.literalMD "`pkgs` module argument"; | ||
}; | ||
packageName = mkOption { | ||
description = '' | ||
Attribute name to use for the generated `package` and `apps` definitions. | ||
You will be able to run `nix run .#<packageName>` to start jupyterlab. | ||
The default value, `"default"` also allows `nix run` without argument, but may compete with other modules' packages. | ||
''; | ||
default = "default"; | ||
}; | ||
}; | ||
|
||
config = { | ||
packages.${cfg.packageName} = jupyterlab; | ||
apps.${cfg.packageName} = { | ||
program = "${jupyterlab}/bin/jupyter-lab"; | ||
type = "app"; | ||
}; | ||
}; | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
description = "Your jupyenv project"; | ||
|
||
nixConfig.extra-substituters = [ | ||
"https://tweag-jupyter.cachix.org" | ||
]; | ||
nixConfig.extra-trusted-public-keys = [ | ||
"tweag-jupyter.cachix.org-1:UtNH4Zs6hVUFpFBTLaA4ejYavPo5EFFqgd7G7FxGW9g=" | ||
]; | ||
|
||
inputs.flake-parts.url = "github:hercules-ci/flake-parts"; | ||
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; | ||
inputs.jupyenv.url = "github:tweag/jupyenv"; | ||
|
||
outputs = inputs @ {flake-parts, ...}: | ||
flake-parts.lib.mkFlake {inherit inputs;} { | ||
imports = [ | ||
inputs.jupyenv.flakeModule | ||
]; | ||
systems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"]; | ||
perSystem = { | ||
lib, | ||
pkgs, | ||
... | ||
}: { | ||
jupyenv.kernels = ./kernels.nix; | ||
}; | ||
}; | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{pkgs, ...}: { | ||
kernel.python.minimal = { | ||
enable = true; | ||
}; | ||
} |