mirror of
https://github.com/ellmau/nixos.git
synced 2025-12-19 09:29:36 +01:00
Add templates to the default flake
This commit is contained in:
parent
cdc16aa257
commit
7d9f73a642
19
flake.nix
19
flake.nix
@ -65,7 +65,7 @@
|
|||||||
(final: prev: {
|
(final: prev: {
|
||||||
elss = (import ./lib { lib = final; }) prev;
|
elss = (import ./lib { lib = final; }) prev;
|
||||||
});
|
});
|
||||||
inherit (extended-lib.elss) discoverModules moduleNames discoverMachines withModules;
|
inherit (extended-lib.elss) discoverModules moduleNames discoverMachines withModules discoverTemplates;
|
||||||
in
|
in
|
||||||
flake-utils-plus.lib.mkFlake rec{
|
flake-utils-plus.lib.mkFlake rec{
|
||||||
inherit self inputs;
|
inherit self inputs;
|
||||||
@ -144,5 +144,22 @@
|
|||||||
sops-nix = inputs.sops-nix.packages."${channels.nixpkgs.system}";
|
sops-nix = inputs.sops-nix.packages."${channels.nixpkgs.system}";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
templates = discoverTemplates ./templates {
|
||||||
|
basic_tool = {
|
||||||
|
description = "Basic setup of tools in nixpkgs/unstable";
|
||||||
|
welcomeText = "Change into the folder and add the wanted packages to the buildInputs";
|
||||||
|
};
|
||||||
|
|
||||||
|
rust = {
|
||||||
|
description = "Rust development environment flake";
|
||||||
|
welcomeText =
|
||||||
|
"Change into the folder and follow the prompt to create an automatic rust environment in this folder";
|
||||||
|
};
|
||||||
|
jupyter = {
|
||||||
|
description = "Jupyter server flake";
|
||||||
|
welcomeText = "Use `nix run .` to run a jupyter server instance.";
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,4 +21,22 @@ with prev; rec {
|
|||||||
discoverMachines = dir: args:
|
discoverMachines = dir: args:
|
||||||
withModules dir ({ path, name }:
|
withModules dir ({ path, name }:
|
||||||
{ modules = [ path ]; } // args);
|
{ modules = [ path ]; } // args);
|
||||||
|
discoverTemplates = dir: overrides:
|
||||||
|
pipe dir [
|
||||||
|
builtins.readDir
|
||||||
|
(filterAttrs (_name: type: type == "directory"))
|
||||||
|
attrNames
|
||||||
|
(map (template:
|
||||||
|
nameValuePair template (recursiveUpdate
|
||||||
|
{
|
||||||
|
path = "${dir}/${template}";
|
||||||
|
description = "a template for ${template} projects";
|
||||||
|
}
|
||||||
|
(if hasAttr template overrides then
|
||||||
|
getAttr template overrides
|
||||||
|
else
|
||||||
|
{ }))))
|
||||||
|
listToAttrs
|
||||||
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
1
templates/basic_tools/.envrc
Normal file
1
templates/basic_tools/.envrc
Normal file
@ -0,0 +1 @@
|
|||||||
|
use flake
|
||||||
31
templates/basic_tools/flake.nix
Normal file
31
templates/basic_tools/flake.nix
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
description = "basic tool setup flake";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.05";
|
||||||
|
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
flake-utils-plus.url = "github:gytis-ivaskevicius/flake-utils-plus";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, nixpkgs-unstable, flake-utils, flake-utils-plus, ... }@inputs:
|
||||||
|
{ } // (flake-utils.lib.eachDefaultSystem (system:
|
||||||
|
let
|
||||||
|
unstable = import nixpkgs-unstable {
|
||||||
|
inherit system;
|
||||||
|
};
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
rec {
|
||||||
|
devShell =
|
||||||
|
pkgs.mkShell {
|
||||||
|
buildInputs = [
|
||||||
|
# add packages here, like
|
||||||
|
# pkgs.clingo
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
));
|
||||||
|
}
|
||||||
45
templates/jupyter/flake.nix
Normal file
45
templates/jupyter/flake.nix
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
description = "JupyterLab Flake";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
jupyterWith.url = "github:tweag/jupyterWith";
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, jupyterWith, flake-utils }:
|
||||||
|
flake-utils.lib.eachSystem [ "x86_64-linux" "x86_64-darwin" ] (system:
|
||||||
|
let
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
system = system;
|
||||||
|
overlays = nixpkgs.lib.attrValues jupyterWith.overlays;
|
||||||
|
};
|
||||||
|
prince = pkgs.python3Packages.buildPythonPackage rec {
|
||||||
|
name = "prince";
|
||||||
|
src = pkgs.fetchFromGitHub{
|
||||||
|
owner = "MaxHalford";
|
||||||
|
repo = "prince";
|
||||||
|
rev = "bd5b29fafe853579c9d41e954caa4504d585665d";
|
||||||
|
sha256 = "X7gpHvy2cfIKMrfSGLZxmJsytLbe/VZd27VsYIyEoTI=";
|
||||||
|
};
|
||||||
|
propagatedBuildInputs = with pkgs.python3Packages; [ matplotlib pandas numpy scipy scikit-learn ];
|
||||||
|
dontCheck = true;
|
||||||
|
dontUseSetuptoolsCheck = true;
|
||||||
|
};
|
||||||
|
iPython = pkgs.kernels.iPythonWith {
|
||||||
|
name = "Python-env";
|
||||||
|
packages = p: with p; [ sympy numpy pandas prince ];
|
||||||
|
ignoreCollisions = true;
|
||||||
|
};
|
||||||
|
jupyterEnvironment = pkgs.jupyterlabWith {
|
||||||
|
kernels = [ iPython ];
|
||||||
|
};
|
||||||
|
in rec {
|
||||||
|
apps.jupterlab = {
|
||||||
|
type = "app";
|
||||||
|
program = "${jupyterEnvironment}/bin/jupyter-lab";
|
||||||
|
};
|
||||||
|
apps.default = apps.jupterlab;
|
||||||
|
devShell = jupyterEnvironment.env;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
1
templates/rust/.envrc
Normal file
1
templates/rust/.envrc
Normal file
@ -0,0 +1 @@
|
|||||||
|
use flake
|
||||||
22
templates/rust/.gitignore
vendored
Normal file
22
templates/rust/.gitignore
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Generated by Cargo
|
||||||
|
# will have compiled files and executables
|
||||||
|
/target/
|
||||||
|
|
||||||
|
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
||||||
|
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
||||||
|
Cargo.lock
|
||||||
|
|
||||||
|
# These are backup files generated by rustfmt
|
||||||
|
**/*.rs.bk
|
||||||
|
|
||||||
|
# Intellij project configuration
|
||||||
|
.idea
|
||||||
|
|
||||||
|
# emacs tmp files
|
||||||
|
*~
|
||||||
|
# Flycheck
|
||||||
|
flycheck_*.el
|
||||||
|
|
||||||
|
# projectiles files
|
||||||
|
.projectile
|
||||||
|
/.direnv/
|
||||||
53
templates/rust/flake.nix
Normal file
53
templates/rust/flake.nix
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
{
|
||||||
|
description = "basic rust flake";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.05";
|
||||||
|
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
rust-overlay = {
|
||||||
|
url = "github:oxalica/rust-overlay";
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.follows = "nixpkgs";
|
||||||
|
flake-utils.follows = "flake-utils";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
gitignoresrc = {
|
||||||
|
url = "github:hercules-ci/gitignore.nix";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, nixpkgs-unstable, flake-utils, gitignoresrc, rust-overlay, ... }@inputs:
|
||||||
|
{
|
||||||
|
#overlay = import ./nix { inherit gitignoresrc; };
|
||||||
|
} // (flake-utils.lib.eachDefaultSystem (system:
|
||||||
|
let
|
||||||
|
unstable = import nixpkgs-unstable { inherit system; };
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
overlays = [ (import rust-overlay)];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
rec {
|
||||||
|
devShell =
|
||||||
|
pkgs.mkShell {
|
||||||
|
RUST_LOG = "debug";
|
||||||
|
RUST_BACKTRACE = 1;
|
||||||
|
buildInputs = [
|
||||||
|
pkgs.rust-bin.stable.latest.rustfmt
|
||||||
|
pkgs.rust-bin.stable.latest.default
|
||||||
|
pkgs.rust-analyzer
|
||||||
|
pkgs.cargo-audit
|
||||||
|
pkgs.cargo-license
|
||||||
|
pkgs.cargo-tarpaulin
|
||||||
|
pkgs.cargo-kcov
|
||||||
|
pkgs.valgrind
|
||||||
|
pkgs.gnuplot
|
||||||
|
pkgs.kcov
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user