diff --git a/flake.nix b/flake.nix index 5d4776cf2..3cad14aaa 100644 --- a/flake.nix +++ b/flake.nix @@ -7,22 +7,30 @@ nixos.url = "nixpkgs/release-20.09"; home.url = "github:nix-community/home-manager/release-20.09"; flake-utils.url = "github:numtide/flake-utils"; + + # DevShells + # Use the nixpkgs master for access to latest tooling. + devshell.url = "github:numtide/devshell/master"; + devshell.inputs.nixpkgs.follows = "master"; # TODO: How does this compare with pkgImport below? + naersk.url = "github:nmattia/naersk"; + naersk.inputs.nixpkgs.follows = "master"; + mozilla-overlay = { url = "github:mozilla/mozilla-nixpkgs"; flake = false; }; }; - outputs = inputs@{ self, home, nixos, master, flake-utils, nur }: + outputs = inputs@{ self, home, nixos, master, flake-utils, nur , devshell, naersk, mozilla-overlay }: let inherit (builtins) attrNames attrValues readDir elem; inherit (flake-utils.lib) eachDefaultSystem; inherit (nixos) lib; inherit (lib) all removeSuffix recursiveUpdate genAttrs filterAttrs; inherit (utils) pathsToImportedAttrs genPkgset overlayPaths modules - genPackages pkgImport; + genPackages pkgImport devShellModules; utils = import ./lib/utils.nix { inherit lib; }; system = "x86_64-linux"; - externOverlays = [ nur.overlay ]; + externOverlays = [ nur.overlay (import mozilla-overlay) devshell.overlay naersk.overlay]; externModules = [ home.nixosModules.home-manager ]; pkgset = @@ -43,6 +51,8 @@ nixosModules = modules; + devShellModules = devShellModules; + templates.flk.path = ./.; templates.flk.description = "flk template"; diff --git a/lib/utils.nix b/lib/utils.nix index 1e8611828..37efc87de 100644 --- a/lib/utils.nix +++ b/lib/utils.nix @@ -82,6 +82,13 @@ in (recursiveUpdate cachixAttrs modulesAttrs) profilesAttrs; + devShellModules = + let + # shells + shellList = import ../shells/list.nix; + in + pathsToImportedAttrs moduleList; + genPackages = { overlay, overlays, pkgs }: let packages = overlay pkgs pkgs; 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..a7ac27749 --- /dev/null +++ b/shells/rust/default.nix @@ -0,0 +1,27 @@ +with pkgs; + +mkDevShell { + name = "Personal Rust DevShell"; + + packages = [ + latest.rustChannels.stable.rust + wasm-bindgen-cli + binaryen + + ncurses + pkgconfig + openssl + openssl.dev + ]; + + env.RUST_BACKTRACE = "1"; + + commands = [ + { + name = "hello"; + help = "say hello"; + category = "fun"; + command = "echo '''hello''' "; + } + ]; +}