From fca8041d90c2c5ab3523e4de3bc058418aac78a2 Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Sat, 20 Aug 2022 15:54:34 +0300 Subject: [PATCH] Reformat all projects; switch to overlay format --- README.md | 13 ++----- clojure/flake.nix | 55 +++++++++++++++------------- cue/flake.nix | 34 +++++++++--------- dhall/flake.nix | 70 ++++++++++++++++-------------------- elixir/flake.nix | 47 +++++++++++------------- elm/flake.nix | 34 +++++++++--------- gleam/flake.nix | 34 +++++++++--------- {go1.17 => go}/.envrc | 0 {go1.17 => go}/flake.lock | 0 go/flake.nix | 39 ++++++++++++++++++++ go1.17/flake.nix | 42 ---------------------- go1.18/.envrc | 1 - go1.18/flake.lock | 42 ---------------------- go1.18/flake.nix | 42 ---------------------- hashi/flake.nix | 46 +++++++++++------------- haskell/flake.nix | 36 ++++++++++--------- java/flake.nix | 52 +++++++++++++++------------ kotlin/flake.nix | 56 +++++++++++++++-------------- nickel/flake.nix | 34 +++++++++--------- nim/flake.nix | 34 +++++++++--------- nix/flake.nix | 29 +++++++-------- node/flake.nix | 38 +++++++++++--------- ocaml/flake.nix | 38 ++++++++++---------- opa/flake.nix | 34 +++++++++--------- protobuf/flake.nix | 33 ++++++++--------- python/flake.nix | 46 ++++++++++++------------ ruby/flake.nix | 38 +++++++++++--------- rust/flake.nix | 75 +++++++++++++++++++++------------------ scala/flake.nix | 56 +++++++++++++++-------------- zig/flake.nix | 34 +++++++++--------- 30 files changed, 532 insertions(+), 600 deletions(-) rename {go1.17 => go}/.envrc (100%) rename {go1.17 => go}/flake.lock (100%) create mode 100644 go/flake.nix delete mode 100644 go1.17/flake.nix delete mode 100644 go1.18/.envrc delete mode 100644 go1.18/flake.lock delete mode 100644 go1.18/flake.nix diff --git a/README.md b/README.md index 443ad6e..f83114c 100644 --- a/README.md +++ b/README.md @@ -35,8 +35,7 @@ Once your preferred template has been initialized, you can use the provided shel | [Elixir] | [`elixir`](./elixir/) | | [Elm] | [`elm`](./elm/) | | [Gleam] | [`gleam`](./gleam/) | -| [Go] 1.17 | [`go1_17`](./go1.17/) | -| [Go] 1.18 | [`go1_18`](./go1.18/) | +| [Go] | [`go`](./go/) | | [Hashicorp] tools | [`hashi`](./hashi/) | | [Java] | [`java`](./java/) | | [Kotlin] | [`kotlin`](./kotlin/) | @@ -96,15 +95,9 @@ The sections below list what each template includes. In all cases, you're free t - [Gleam] 0.22.1 -### [`go1.17`](./go1.17/) +### [`go`](./go/) -- [Go] 1.17 -- Standard Go tools ([goimports], [godoc], and others) -- [golangci-lint] - -### [`go1.18`](./go1.18/) - -- [Go] 1.18 +- [Go] 1.19 - Standard Go tools ([goimports], [godoc], and others) - [golangci-lint] diff --git a/clojure/flake.nix b/clojure/flake.nix index 4d79594..e440944 100644 --- a/clojure/flake.nix +++ b/clojure/flake.nix @@ -6,31 +6,38 @@ nixpkgs.url = "github:NixOS/nixpkgs"; }; - outputs = { self, flake-utils, nixpkgs }: + outputs = + { self + , flake-utils + , nixpkgs + }: + flake-utils.lib.eachDefaultSystem (system: - let - jdk = "jdk17"; - - config = { - packageOverrides = p: { - boot = p.boot.override { jdk = p.${jdk}; }; - clojure = p.clojure.override { jdk = p.${jdk}; }; - leiningen = p.leiningen.override { jdk = p.${jdk}; }; + let + javaVersion = 17; + overlays = [ + (self: super: rec { + jdk = super."jdk${toString javaVersion}"; + boot = super.boot.override { + inherit jdk; }; - }; - - pkgs = import nixpkgs { inherit config system; }; - inherit (pkgs) boot clojure leiningen mkShell; - in - { - devShells = { - default = mkShell { - buildInputs = [ boot clojure leiningen ]; - - shellHook = '' - ${clojure}/bin/clj --version - ''; + clojure = super.clojure.override { + inherit jdk; }; - }; - }); + leiningen = super.leiningen.override { + inherit jdk; + }; + }) + ]; + pkgs = import nixpkgs { inherit overlays system; }; + in + { + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ boot clojure leiningen ]; + + shellHook = '' + ${pkgs.clojure}/bin/clj --version + ''; + }; + }); } diff --git a/cue/flake.nix b/cue/flake.nix index b185db4..ee28e0f 100644 --- a/cue/flake.nix +++ b/cue/flake.nix @@ -6,21 +6,23 @@ nixpkgs.url = "github:NixOS/nixpkgs"; }; - outputs = { self, flake-utils, nixpkgs }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; - inherit (pkgs) cue mkShell; - in - { - devShells = { - default = mkShell { - buildInputs = [ cue ]; + outputs = + { self + , flake-utils + , nixpkgs + }: - shellHook = '' - ${cue}/bin/cue version - ''; - }; - }; - }); + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + in + { + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ cue ]; + + shellHook = '' + ${pkgs.cue}/bin/cue version + ''; + }; + }); } diff --git a/dhall/flake.nix b/dhall/flake.nix index 61a2187..c6d7813 100644 --- a/dhall/flake.nix +++ b/dhall/flake.nix @@ -6,47 +6,39 @@ nixpkgs.url = "github:NixOS/nixpkgs"; }; - outputs = { self, flake-utils, nixpkgs }: + outputs = + { self + , flake-utils + , nixpkgs + }: + flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; - dhall = pkgs.dhall; + let + pkgs = import nixpkgs { inherit system; }; - inherit (pkgs) mkShell; - inherit (pkgs.lib) optionals; - inherit (pkgs.stdenv) isLinux; + # Helper function for building dhall-* tools + mkDhallTools = ls: + builtins.map (tool: pkgs.haskellPackages."dhall-${tool}") ls; - # Helper function for building dhall-* tools - mkDhallTools = ls: - builtins.map (tool: pkgs.haskellPackages."dhall-${tool}") ls; + dhallTools = mkDhallTools [ + "bash" + "docs" + "json" + "lsp-server" + "nix" + "nixpkgs" + "openapi" + "toml" + "yaml" + ] ++ pkgs.lib.optionals (pkgs.stdenv.isLinux) (mkDhallTools [ "csv" "text" ]); # Linux only + in + { + devShell = pkgs.mkShell { + buildInputs = (with pkgs; [ dhall ]) ++ dhallTools; - # dhall-* tools available only on all platforms - dhallToolsCommon = mkDhallTools [ - "bash" - "docs" - "json" - "lsp-server" - "nix" - "nixpkgs" - "openapi" - "toml" - "yaml" - ]; - - # dhall-* tools available only on Linux - dhallToolsLinux = optionals isLinux (mkDhallTools [ "csv" "text" ]); - - dhallTools = dhallToolsCommon ++ dhallToolsLinux; - in - { - devShells = { - default = mkShell { - buildInputs = [ dhall ] ++ dhallTools; - - shellHook = '' - echo "dhall `${dhall}/bin/dhall --version`" - ''; - }; - }; - }); + shellHook = '' + echo "dhall `${pkgs.dhall}/bin/dhall --version`" + ''; + }; + }); } diff --git a/elixir/flake.nix b/elixir/flake.nix index a56d712..a6a2ece 100644 --- a/elixir/flake.nix +++ b/elixir/flake.nix @@ -6,32 +6,27 @@ nixpkgs.url = "github:NixOS/nixpkgs"; }; - outputs = { self, flake-utils, nixpkgs }: + outputs = + { self + , flake-utils + , nixpkgs + }: + flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; + let + pkgs = import nixpkgs { inherit system; }; + in + { + devShell = pkgs.mkShell { + buildInputs = (with pkgs; [ elixir ]) ++ + pkgs.lib.optionals (pkgs.stdenv.isLinux) (with pkgs; [ gigalixir inotify-tools libnotify ]) ++ # Linux only + pkgs.lib.optionals (pkgs.stdenv.isDarwin) (with pkgs; [ terminal-notifier ]) ++ # macOS only + (with pkgs.darwin.apple_sdk.frameworks; [ CoreFoundation CoreServices ]); - inherit (pkgs) - darwin gigalixir inotify-tools libnotify mkShell terminal-notifier; - inherit (pkgs.beam.packages.erlangR25) elixir elixir_ls; - inherit (pkgs.darwin.apple_sdk.frameworks) CoreFoundation CoreServices; - inherit (pkgs.lib) optionals; - inherit (pkgs.stdenv) isDarwin isLinux; - - linuxDeps = optionals isLinux [ gigalixir inotify-tools libnotify ]; - darwinDeps = optionals isDarwin [ terminal-notifier ] - ++ [ CoreFoundation CoreServices ]; - in - { - devShells = { - default = mkShell { - buildInputs = [ elixir elixir_ls ] ++ linuxDeps ++ darwinDeps; - - shellHook = '' - ${elixir}/bin/mix --version - ${elixir}/bin/iex --version - ''; - }; - }; - }); + shellHook = '' + ${pkgs.elixir}/bin/mix --version + ${pkgs.elixir}/bin/iex --version + ''; + }; + }); } diff --git a/elm/flake.nix b/elm/flake.nix index cffc275..a2cabbe 100644 --- a/elm/flake.nix +++ b/elm/flake.nix @@ -6,23 +6,23 @@ nixpkgs.url = "github:NixOS/nixpkgs"; }; - outputs = { self, flake-utils, nixpkgs }: + outputs = + { self + , flake-utils + , nixpkgs + }: + flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; - inherit (pkgs) mkShell; + let + pkgs = import nixpkgs { inherit system; }; + in + { + devShell = pkgs.mkShell { + buildInputs = (with pkgs.elmPackages; [ elm ]) ++ (with pkgs; [ elm2nix ]); - elm = pkgs.elmPackages.elm; - in - { - devShells = { - default = mkShell { - buildInputs = [ elm ] ++ (with pkgs; [ elm2nix ]); - - shellHook = '' - echo "elm `${elm}/bin/elm --version`" - ''; - }; - }; - }); + shellHook = with pkgs.elmPackages; '' + echo "elm `${elm}/bin/elm --version`" + ''; + }; + }); } diff --git a/gleam/flake.nix b/gleam/flake.nix index a8bd243..093ccdc 100644 --- a/gleam/flake.nix +++ b/gleam/flake.nix @@ -6,23 +6,23 @@ nixpkgs.url = "github:NixOS/nixpkgs"; }; - outputs = { self, flake-utils, nixpkgs }: + outputs = + { self + , flake-utils + , nixpkgs + }: + flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; - gleamPkg = pkgs.gleam; + let + pkgs = import nixpkgs { inherit system; }; + in + { + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ gleam ]; - inherit (pkgs) mkShell; - in - { - devShells = { - default = mkShell { - buildInputs = [ gleamPkg ]; - - shellHook = '' - ${gleamPkg}/bin/gleam --version - ''; - }; - }; - }); + shellHook = '' + ${pkgs.gleam}/bin/gleam --version + ''; + }; + }); } diff --git a/go1.17/.envrc b/go/.envrc similarity index 100% rename from go1.17/.envrc rename to go/.envrc diff --git a/go1.17/flake.lock b/go/flake.lock similarity index 100% rename from go1.17/flake.lock rename to go/flake.lock diff --git a/go/flake.nix b/go/flake.nix new file mode 100644 index 0000000..ac43480 --- /dev/null +++ b/go/flake.nix @@ -0,0 +1,39 @@ +{ + description = "A Nix-flake-based Go 1.17 development environment"; + + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:NixOS/nixpkgs"; + }; + + outputs = + { self + , flake-utils + , nixpkgs + }: + + flake-utils.lib.eachDefaultSystem (system: + let + goVersion = 19; + overlays = [ (self: super: { go = super."go_1_${toString goVersion}"; }) ]; + pkgs = import nixpkgs { inherit overlays system; }; + in + { + devShell = pkgs.mkShellNoCC { + buildInputs = with pkgs; [ + # go 1.17.1 (specified by overlay) + go + + # goimports, godoc, etc. + gotools + + # https://github.com/golangci/golangci-lint + golangci-lint + ]; + + shellHook = '' + ${pkgs.go}/bin/go version + ''; + }; + }); +} diff --git a/go1.17/flake.nix b/go1.17/flake.nix deleted file mode 100644 index 5ef8219..0000000 --- a/go1.17/flake.nix +++ /dev/null @@ -1,42 +0,0 @@ -{ - description = "A Nix-flake-based Go 1.17 development environment"; - - inputs = { - flake-utils.url = "github:numtide/flake-utils"; - nixpkgs.url = "github:NixOS/nixpkgs"; - }; - - outputs = { self, flake-utils, nixpkgs }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; - goPkg = pkgs.go_1_17; - - inherit (pkgs) mkShellNoCC; - in - { - apps.default = { - type = "app"; - program = "${goPkg}/bin/go"; - }; - - devShells = { - default = mkShellNoCC { - buildInputs = with pkgs; [ - # go 1.17.1 - goPkg - - # goimports, godoc, etc. - gotools - - # https://github.com/golangci/golangci-lint - golangci-lint - ]; - - shellHook = '' - ${goPkg}/bin/go version - ''; - }; - }; - }); -} diff --git a/go1.18/.envrc b/go1.18/.envrc deleted file mode 100644 index a5dbbcb..0000000 --- a/go1.18/.envrc +++ /dev/null @@ -1 +0,0 @@ -use flake . diff --git a/go1.18/flake.lock b/go1.18/flake.lock deleted file mode 100644 index 070c1f3..0000000 --- a/go1.18/flake.lock +++ /dev/null @@ -1,42 +0,0 @@ -{ - "nodes": { - "flake-utils": { - "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1660984654, - "narHash": "sha256-fDcsh8rm2o8cj+WFL8Y2cAqnsej0UGJa+Sy8U2nFg0Q=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "392c83491dcc21d17ab8ea1f809f8f7bd567a5a3", - "type": "github" - }, - "original": { - "owner": "NixOS", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/go1.18/flake.nix b/go1.18/flake.nix deleted file mode 100644 index f4c40cd..0000000 --- a/go1.18/flake.nix +++ /dev/null @@ -1,42 +0,0 @@ -{ - description = "A Nix-flake-based Go 1.18 development environment"; - - inputs = { - flake-utils.url = "github:numtide/flake-utils"; - nixpkgs.url = "github:NixOS/nixpkgs"; - }; - - outputs = { self, flake-utils, nixpkgs }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; - goPkg = pkgs.go_1_18; - - inherit (pkgs) mkShellNoCC; - in - { - apps.default = { - type = "app"; - program = "${goPkg}/bin/go"; - }; - - devShells = { - default = mkShellNoCC { - buildInputs = with pkgs; [ - # go 1.18.3 - goPkg - - # goimports, godoc, etc. - gotools - - # https://github.com/golangci/golangci-lint - golangci-lint - ]; - - shellHook = '' - ${goPkg}/bin/go version - ''; - }; - }; - }); -} diff --git a/hashi/flake.nix b/hashi/flake.nix index 56ac35e..3fcb964 100644 --- a/hashi/flake.nix +++ b/hashi/flake.nix @@ -7,16 +7,19 @@ nixpkgs.url = "github:NixOS/nixpkgs"; }; - outputs = { self, flake-utils, nixpkgs }: + outputs = + { self + , flake-utils + , nixpkgs + }: + flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; - - inherit (pkgs) - damon levant mkShell nomad nomad-autoscaler nomad-pack packer - terraform vault; - - hashiTools = [ + let + pkgs = import nixpkgs { inherit system; }; + in + { + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ packer terraform nomad @@ -25,22 +28,15 @@ nomad-pack levant damon + terragrunt ]; - relatedTools = with pkgs; [ terragrunt ]; - in - { - devShells = { - default = mkShell { - buildInputs = hashiTools ++ relatedTools; - - shellHook = '' - echo "packer `${packer}/bin/packer --version`" - ${terraform}/bin/terraform --version - ${nomad}/bin/nomad --version - ${vault}/bin/vault --version - ''; - }; - }; - }); + shellHook = with pkgs; '' + echo "packer `${packer}/bin/packer --version`" + ${terraform}/bin/terraform --version + ${nomad}/bin/nomad --version + ${vault}/bin/vault --version + ''; + }; + }); } diff --git a/haskell/flake.nix b/haskell/flake.nix index 240a14b..505b5c6 100644 --- a/haskell/flake.nix +++ b/haskell/flake.nix @@ -6,22 +6,24 @@ nixpkgs.url = "github:NixOS/nixpkgs"; }; - outputs = { self, flake-utils, nixpkgs }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; - inherit (pkgs) cabal-install ghc mkShell; - in - { - devShells = { - default = mkShell { - buildInputs = [ cabal-install ghc ]; + outputs = + { self + , flake-utils + , nixpkgs + }: - shellHook = '' - ${ghc}/bin/ghc --version - ${cabal-install}/bin/cabal --version - ''; - }; - }; - }); + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + in + { + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ cabal-install ghc ]; + + shellHook = with pkgs; '' + ${ghc}/bin/ghc --version + ${cabal-install}/bin/cabal --version + ''; + }; + }); } diff --git a/java/flake.nix b/java/flake.nix index f327551..bb4fba5 100644 --- a/java/flake.nix +++ b/java/flake.nix @@ -6,31 +6,37 @@ nixpkgs.url = "github:NixOS/nixpkgs"; }; - outputs = { self, flake-utils, nixpkgs }: + outputs = + { self + , flake-utils + , nixpkgs + }: + flake-utils.lib.eachDefaultSystem (system: - let - jdk = pkgs.jdk17; + let + javaVersion = 17; - config = { - packageOverrides = p: { - gradle = (p.gradle.override { java = jdk; }); + overlays = [ + (self: super: rec { + jdk = super."jdk${toString javaVersion}"; + gradle = super.gradle.override { + java = jdk; }; - }; - - pkgs = import nixpkgs { inherit config jdk system; }; - java = jdk; - buildTools = with pkgs; [ ant gradle maven ]; - inherit (pkgs) mkShell; - in - { - devShells = { - default = mkShell { - buildInputs = [ java ] ++ buildTools; - - shellHook = '' - ${java}/bin/java -version - ''; + maven = super.maven.override { + inherit jdk; }; - }; - }); + }) + ]; + + pkgs = import nixpkgs { inherit overlays system; }; + in + { + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ gradle jdk maven ]; + + shellHook = '' + ${pkgs.jdk}/bin/java -version + ''; + }; + }); } diff --git a/kotlin/flake.nix b/kotlin/flake.nix index 99c3a73..488a2ee 100644 --- a/kotlin/flake.nix +++ b/kotlin/flake.nix @@ -6,35 +6,37 @@ nixpkgs.url = "github:NixOS/nixpkgs"; }; - outputs = { self, flake-utils, nixpkgs }: + outputs = + { self + , flake-utils + , nixpkgs + }: + flake-utils.lib.eachDefaultSystem (system: - let - jdk = pkgs.jdk17; + let + javaVersion = 17; - config = { - packageOverrides = p: { - gradle = (p.gradle.override { java = jdk; }); - - kotlin = (p.kotlin.override { jre = jdk; }); + overlays = [ + (self: super: rec { + jdk = pkgs."jdk${toString javaVersion}"; + gradle = super.gradle.override { + java = jdk; }; - }; - - pkgs = import nixpkgs { inherit config system; }; - inherit (pkgs) mkShell; - - kotlin = pkgs.kotlin; - buildTools = with pkgs; [ gradle ]; - otherTools = with pkgs; [ gcc ncurses patchelf zlib ]; - in - { - devShells = { - default = mkShell { - buildInputs = [ kotlin ] ++ buildTools ++ otherTools; - - shellHook = '' - ${kotlin}/bin/kotlin -version - ''; + kotlin = super.kotlin.override { + jre = jdk; }; - }; - }); + }) + ]; + + pkgs = import nixpkgs { inherit overlays system; }; + in + { + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ kotlin gradle gcc ncurses patchelf zlib ]; + + shellHook = '' + ${pkgs.kotlin}/bin/kotlin -version + ''; + }; + }); } diff --git a/nickel/flake.nix b/nickel/flake.nix index 94a0904..d7157ff 100644 --- a/nickel/flake.nix +++ b/nickel/flake.nix @@ -6,21 +6,23 @@ nixpkgs.url = "github:NixOS/nixpkgs"; }; - outputs = { self, flake-utils, nixpkgs }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; - inherit (pkgs) mkShell nickel; - in - { - devShells = { - default = mkShell { - buildInputs = [ nickel ]; + outputs = + { self + , flake-utils + , nixpkgs + }: - shellHook = '' - ${nickel}/bin/nickel --version - ''; - }; - }; - }); + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + in + { + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ nickel ]; + + shellHook = '' + ${pkgs.nickel}/bin/nickel --version + ''; + }; + }); } diff --git a/nim/flake.nix b/nim/flake.nix index e270319..a67f6f0 100644 --- a/nim/flake.nix +++ b/nim/flake.nix @@ -6,21 +6,23 @@ nixpkgs.url = "github:NixOS/nixpkgs"; }; - outputs = { self, flake-utils, nixpkgs }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; - inherit (pkgs) mkShell nim; - in - { - devShells = { - default = mkShell { - buildInputs = [ nim ]; + outputs = + { self + , flake-utils + , nixpkgs + }: - shellHook = '' - ${nim}/bin/nim --version - ''; - }; - }; - }); + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + in + { + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ nim ]; + + shellHook = '' + ${pkgs.nim}/bin/nim --version + ''; + }; + }); } diff --git a/nix/flake.nix b/nix/flake.nix index 23a1b95..6c931e9 100644 --- a/nix/flake.nix +++ b/nix/flake.nix @@ -6,26 +6,27 @@ nixpkgs.url = "github:NixOS/nixpkgs"; }; - outputs = { self, flake-utils, nixpkgs }: + outputs = + { self + , flake-utils + , nixpkgs + }: + flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; - - dhallNix = pkgs.haskellPackages.dhall-nix; - - nixRelatedTools = with pkgs; [ + let + pkgs = import nixpkgs { inherit system; }; + in + { + devShell = { + buildInputs = with pkgs; [ cachix - dhallNix lorri niv nixfmt statix vulnix + haskellPackages.dhall-nix ]; - - inherit (pkgs) mkShell; - in - { - devShells = { default = mkShell { buildInputs = nixRelatedTools; }; }; - }); + }; + }); } diff --git a/node/flake.nix b/node/flake.nix index 94810ec..7fba182 100644 --- a/node/flake.nix +++ b/node/flake.nix @@ -6,26 +6,30 @@ nixpkgs.url = "github:NixOS/nixpkgs"; }; - outputs = { self, flake-utils, nixpkgs }: + outputs = + { self + , flake-utils + , nixpkgs + }: + flake-utils.lib.eachDefaultSystem (system: - let - nodeOverlay = self: super: rec { + let + overlays = [ + (self: super: rec { nodejs = super.nodejs-18_x; pnpm = super.nodePackages.pnpm; yarn = (super.yarn.override { inherit nodejs; }); - }; - overlays = [ nodeOverlay ]; - pkgs = import nixpkgs { inherit overlays system; }; - in - { - devShells = { - default = pkgs.mkShell { - buildInputs = with pkgs; [ node2nix nodejs pnpm yarn ]; + }) + ]; + pkgs = import nixpkgs { inherit overlays system; }; + in + { + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ node2nix nodejs pnpm yarn ]; - shellHook = '' - echo "node `${pkgs.nodejs}/bin/node --version`" - ''; - }; - }; - }); + shellHook = '' + echo "node `${pkgs.nodejs}/bin/node --version`" + ''; + }; + }); } diff --git a/ocaml/flake.nix b/ocaml/flake.nix index e1cf7b5..800e6d9 100644 --- a/ocaml/flake.nix +++ b/ocaml/flake.nix @@ -6,24 +6,24 @@ nixpkgs.url = "github:NixOS/nixpkgs"; }; - outputs = { self, flake-utils, nixpkgs }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; - inherit (pkgs) mkShell; - ocaml = pkgs.ocamlPackages.ocaml; - ocamlTools = with pkgs.ocamlPackages; - [ dune_3 odoc ] ++ (with pkgs; [ ocamlformat ]); - in - { - devShells = { - default = mkShell { - buildInputs = [ ocaml ] ++ ocamlTools; + outputs = + { self + , flake-utils + , nixpkgs + }: - shellHook = '' - ${ocaml}/bin/ocaml --version - ''; - }; - }; - }); + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + in + { + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ ocaml ocamlformat ] ++ + (with pkgs.ocamlPackages; [ dune_3 odoc ]); + + shellHook = '' + ${pkgs.ocaml}/bin/ocaml --version + ''; + }; + }); } diff --git a/opa/flake.nix b/opa/flake.nix index a82f479..4d6599b 100644 --- a/opa/flake.nix +++ b/opa/flake.nix @@ -6,23 +6,23 @@ nixpkgs.url = "github:NixOS/nixpkgs"; }; - outputs = { self, flake-utils, nixpkgs }: + outputs = + { self + , flake-utils + , nixpkgs + }: + flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; - inherit (pkgs) conftest mkShell open-policy-agent; + let + pkgs = import nixpkgs { inherit system; }; + in + { + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ open-policy-agent conftest ]; - opaTools = [ conftest open-policy-agent ]; - in - { - devShells = { - default = mkShell { - buildInputs = opaTools; - - shellHook = '' - ${open-policy-agent}/bin/opa version - ''; - }; - }; - }); + shellHook = '' + ${pkgs.open-policy-agent}/bin/opa version + ''; + }; + }); } diff --git a/protobuf/flake.nix b/protobuf/flake.nix index a3176ae..b4bb3bf 100644 --- a/protobuf/flake.nix +++ b/protobuf/flake.nix @@ -6,22 +6,23 @@ nixpkgs.url = "github:NixOS/nixpkgs"; }; - outputs = { self, flake-utils, nixpkgs }: + outputs = + { self + , flake-utils + , nixpkgs + }: flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; - inherit (pkgs) buf mkShell protobuf; - in - { - devShells = { - default = mkShell { - buildInputs = [ buf protobuf ]; + let + pkgs = import nixpkgs { inherit system; }; + in + { + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ buf protobuf ]; - shellHook = '' - echo "buf `${buf}/bin/buf --version`" - ${protobuf}/bin/protoc --version - ''; - }; - }; - }); + shellHook = with pkgs; '' + echo "buf `${buf}/bin/buf --version`" + ${protobuf}/bin/protoc --version + ''; + }; + }); } diff --git a/python/flake.nix b/python/flake.nix index f153a9d..8cd5c1a 100644 --- a/python/flake.nix +++ b/python/flake.nix @@ -7,29 +7,31 @@ nixpkgs.url = "github:NixOS/nixpkgs"; }; - outputs = { self, flake-utils, mach-nix, nixpkgs }: + outputs = + { self + , flake-utils + , mach-nix + , nixpkgs + }: flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; - inherit (pkgs) mkShell; + let + overlays = [ + (self: super: { + machNix = mach-nix.defaultPackage.${system}; + python = super.python311; + }) + ]; - python = pkgs.python311; + pkgs = import nixpkgs { inherit overlays system; }; + in + { + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ python machNix virtualenv ] ++ + (with pkgs.python311Packages; [ pip ]); - machNix = mach-nix.defaultPackage.${system}; - - pythonTools = with pkgs; - [ virtualenv ] ++ (with pkgs.python311Packages; [ pip ]); - nixTools = [ machNix ]; - in - { - devShells = { - default = mkShell { - buildInputs = [ python ] ++ pythonTools ++ nixTools; - - shellHook = '' - ${python}/bin/python --version - ''; - }; - }; - }); + shellHook = '' + ${pkgs.python}/bin/python --version + ''; + }; + }); } diff --git a/ruby/flake.nix b/ruby/flake.nix index 2b9db26..91d97aa 100644 --- a/ruby/flake.nix +++ b/ruby/flake.nix @@ -6,23 +6,27 @@ nixpkgs.url = "github:NixOS/nixpkgs"; }; - outputs = { self, flake-utils, nixpkgs }: + outputs = + { self + , flake-utils + , nixpkgs + }: flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; - inherit (pkgs) mkShell; + let + overlays = [ + (self: super: { + ruby = super.ruby_3_1; + }) + ]; + pkgs = import nixpkgs { inherit overlays system; }; + in + { + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ ruby ]; - ruby = pkgs.ruby_3_1; - in - { - devShells = { - default = mkShell { - buildInputs = [ ruby ]; - - shellHook = '' - ${ruby}/bin/ruby --version - ''; - }; - }; - }); + shellHook = '' + ${pkgs.ruby}/bin/ruby --version + ''; + }; + }); } diff --git a/rust/flake.nix b/rust/flake.nix index 1b56f52..6650643 100644 --- a/rust/flake.nix +++ b/rust/flake.nix @@ -7,41 +7,48 @@ rust-overlay.url = "github:oxalica/rust-overlay"; }; - outputs = { self, flake-utils, nixpkgs, rust-overlay }: + outputs = + { self + , flake-utils + , nixpkgs + , rust-overlay + }: + flake-utils.lib.eachDefaultSystem (system: - let - overlays = [ (import rust-overlay) ]; + let + overlays = [ + (import rust-overlay) + (self: super: { + rustToolchain = + let + rust = super.rust-bin; + in + if builtins.pathExists ./rust-toolchain.toml then + rust.fromRustupToolchainFile ./rust-toolchain.toml + else if builtins.pathExists ./rust-toolchain then + rust.fromRustupToolchainFile ./rust-toolchain + else + rust.stable.latest.default; + }) + ]; - pkgs = import nixpkgs { inherit system overlays; }; + pkgs = import nixpkgs { inherit system overlays; }; + in + { + devShell = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + rustToolchain + openssl + pkg-config + cargo-audit + cargo-deny + cargo-cross + rust-analyzer + ] ++ pkgs.lib.optionals (pkgs.stdenv.isLinux) (with pkgs; [ cargo-watch ]); # Currently broken on macOS - inherit (pkgs) mkShell rust-bin; - inherit (pkgs.lib) optionals; - inherit (pkgs.stdenv) isLinux; - - rust = - if builtins.pathExists ./rust-toolchain.toml then - rust-bin.fromRustupToolchainFile ./rust-toolchain.toml - else if builtins.pathExists ./rust-toolchain then - rust-bin.fromRustupToolchainFile ./rust-toolchain - else - rust-bin.stable.latest.default; - - deps = with pkgs; [ openssl pkgconfig ]; - rustTools = with pkgs; - [ cargo-audit cargo-deny cargo-cross rust-analyzer ] - ++ optionals isLinux (with pkgs; [ cargo-watch ]); - in - { - packages.default = rust; - - devShells = { - default = mkShell { - nativeBuildInputs = [ rust ] ++ deps ++ rustTools; - - shellHook = '' - ${rust}/bin/cargo --version - ''; - }; - }; - }); + shellHook = '' + ${pkgs.rustToolchain}/bin/cargo --version + ''; + }; + }); } diff --git a/scala/flake.nix b/scala/flake.nix index 90d7d21..76b8129 100644 --- a/scala/flake.nix +++ b/scala/flake.nix @@ -6,35 +6,37 @@ nixpkgs.url = "github:NixOS/nixpkgs"; }; - outputs = { self, flake-utils, nixpkgs }: + outputs = + { self + , flake-utils + , nixpkgs + }: flake-utils.lib.eachDefaultSystem (system: - let - jdk = "jdk17"; - config = { - packageOverrides = p: { - sbt = p.sbt.override { jre = p.${jdk}; }; - scala_3 = p.scala_3.override { jre = p.${jdk}; }; + let + javaVersion = 17; + + overlays = [ + (self: super: rec { + jdk = super."jdk${toString javaVersion}"; + sbt = super.sbt.override { + jre = jdk; }; - }; - - pkgs = import nixpkgs { inherit config jdk system; }; - - inherit (pkgs) mkShell; - - scala = pkgs.scala_3; - - buildTools = with pkgs; [ sbt ]; - in - { - devShells = { - default = mkShell { - buildInputs = [ scala ] ++ buildTools; - - shellHook = '' - ${scala}/bin/scala -version - ''; + scala = super.scala_3.override { + jre = jdk; }; - }; - }); + }) + ]; + + pkgs = import nixpkgs { inherit overlays system; }; + in + { + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ scala sbt coursier ]; + + shellHook = '' + ${pkgs.scala}/bin/scala -version + ''; + }; + }); } diff --git a/zig/flake.nix b/zig/flake.nix index 842940c..7ab0ba9 100644 --- a/zig/flake.nix +++ b/zig/flake.nix @@ -6,23 +6,23 @@ nixpkgs.url = "github:NixOS/nixpkgs"; }; - outputs = { self, flake-utils, nixpkgs }: + outputs = + { self + , flake-utils + , nixpkgs + }: + flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; - zigPkg = pkgs.zig; + let + pkgs = import nixpkgs { inherit system; }; + in + { + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ zig ]; - inherit (pkgs) mkShell; - in - { - devShells = { - default = mkShell { - buildInputs = [ zigPkg ]; - - shellHook = '' - echo "zig `${zigPkg}/bin/zig version`" - ''; - }; - }; - }); + shellHook = '' + echo "zig `${pkgs.zig}/bin/zig version`" + ''; + }; + }); }