diff --git a/flake.nix b/flake.nix index 91b990c28..1bbee5860 100644 --- a/flake.nix +++ b/flake.nix @@ -8,9 +8,11 @@ home.url = "github:nix-community/home-manager/release-20.09"; flake-utils.url = "github:numtide/flake-utils"; devshell.url = "github:numtide/devshell"; + naersk.url = "github:nmattia/naersk"; + mozilla-overlay = { url = "github:mozilla/mozilla-nixpkgs"; flake = false; }; }; - outputs = inputs@{ self, home, nixos, master, flake-utils, nur, devshell }: + outputs = inputs@{ self, home, nixos, master, flake-utils, nur, devshell, naersk, mozilla-overlay }: let inherit (builtins) attrNames attrValues readDir elem pathExists filter; inherit (flake-utils.lib) eachDefaultSystem mkApp; @@ -18,13 +20,13 @@ inherit (lib) all removeSuffix recursiveUpdate genAttrs filterAttrs mapAttrs; inherit (utils) pathsToImportedAttrs genPkgset overlayPaths modules - genPackages pkgImport; + genPackages pkgImport devshells; utils = import ./lib/utils.nix { inherit lib; }; system = "x86_64-linux"; - externOverlays = [ nur.overlay devshell.overlay ]; + externOverlays = [ nur.overlay devshell.overlay (import mozilla-overlay) naersk.overlay]; externModules = [ home.nixosModules.home-manager ]; pkgset = @@ -45,6 +47,8 @@ nixosModules = modules; + devshellModules = devshells; + templates.flk.path = ./.; templates.flk.description = "flk template"; diff --git a/lib/utils.nix b/lib/utils.nix index 1e8611828..eb88b492f 100644 --- a/lib/utils.nix +++ b/lib/utils.nix @@ -82,6 +82,13 @@ in (recursiveUpdate cachixAttrs modulesAttrs) profilesAttrs; + devshells = + let + # shells + shellList = import ../shells/list.nix; + in + pathsToImportedAttrs shellList; + genPackages = { overlay, overlays, pkgs }: let packages = overlay pkgs pkgs; diff --git a/shell.nix b/shell.nix index d55dd5f82..ca4ce051e 100644 --- a/shell.nix +++ b/shell.nix @@ -30,6 +30,10 @@ let name = "flk"; in pkgs.mkDevShell { + + imports = [ (import ./shells/rust) ]; + nixflk.rust.enable = true; + inherit name; packages = with pkgs; with installPkgs; [ diff --git a/shells/list.nix b/shells/list.nix new file mode 100644 index 000000000..2c5161c55 --- /dev/null +++ b/shells/list.nix @@ -0,0 +1,3 @@ +[ + ./rust +] diff --git a/shells/rust/default.nix b/shells/rust/default.nix new file mode 100644 index 000000000..714abfb5d --- /dev/null +++ b/shells/rust/default.nix @@ -0,0 +1,32 @@ +{ config, lib, ... }: { + options.nixflk.rust = { + enable = lib.mkEnableOption "nixflk.rust"; + openssl = lib.mkEnableOption "nixflk.rust.openssl"; + }; + config = lib.optionalAttrs nixflk.rust.enable { + name = "Nixflk Rust DevShell"; + + packages = [ + latest.rustChannels.stable.rust + wasm-bindgen-cli + binaryen + + ncurses + pkgconfig + ] ++ lib.mkIf options.nixflk.rust.openssl [ + openssl + openssl.dev + ]; + + env.RUST_BACKTRACE = "1"; + + commands = [ + { + name = "hello"; + help = "say hello"; + category = "fun"; + command = "echo '''hello''' "; + } + ]; + }; +}