From 20e8cf86756fd84b580e2d65df72d7a9020c18f7 Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Thu, 28 Jul 2022 23:20:46 +0200 Subject: [PATCH] Basic repo cleanup --- rust/.gitignore => .gitignore | 0 README.md | 6 +++++ flake.nix | 10 +++++++++ gleam/.envrc | 1 + gleam/flake.lock | 42 +++++++++++++++++++++++++++++++++++ gleam/flake.nix | 30 +++++++++++++++++++++++++ go1.17/.envrc | 3 --- go1.17/.gitignore | 1 - go1.17/flake.nix | 9 ++++---- go1.18/.envrc | 3 --- go1.18/.gitignore | 1 - go1.18/flake.nix | 9 ++++---- rust/.envrc | 3 --- rust/Cargo.lock | 7 ------ rust/Cargo.toml | 8 ------- rust/flake.nix | 3 ++- rust/rust-toolchain.toml | 2 +- rust/src/main.rs | 3 --- zig/.envrc | 1 + zig/flake.lock | 42 +++++++++++++++++++++++++++++++++++ zig/flake.nix | 30 +++++++++++++++++++++++++ 21 files changed, 175 insertions(+), 39 deletions(-) rename rust/.gitignore => .gitignore (100%) create mode 100644 gleam/.envrc create mode 100644 gleam/flake.lock create mode 100644 gleam/flake.nix delete mode 100644 go1.17/.gitignore delete mode 100644 go1.18/.gitignore delete mode 100644 rust/Cargo.lock delete mode 100644 rust/Cargo.toml delete mode 100644 rust/src/main.rs create mode 100644 zig/.envrc create mode 100644 zig/flake.lock create mode 100644 zig/flake.nix diff --git a/rust/.gitignore b/.gitignore similarity index 100% rename from rust/.gitignore rename to .gitignore diff --git a/README.md b/README.md index 6d96805..d9a61bc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # Nix flake templates for easy dev environments ```shell +# Gleam +nix flake init --template github:the-nix-way/dev-templates#gleam + # Go 1.17 nix flake init --template github:the-nix-way/dev-templates#go_1_17 @@ -9,4 +12,7 @@ nix flake init --template github:the-nix-way/dev-templates#go_1_18 # Rust nix flake init --template github:the-nix-way/dev-templates#rust + +# Zig +nix flake init --template github:the-nix-way/dev-templates#rust ``` diff --git a/flake.nix b/flake.nix index 522b2cd..afc61b3 100644 --- a/flake.nix +++ b/flake.nix @@ -3,6 +3,11 @@ outputs = { self }: { templates = { + gleam = { + path = ./gleam; + description = "Gleam development environment"; + }; + go_1_17 = { path = ./go1.17; description = "Go 1.17 development environment"; @@ -17,6 +22,11 @@ path = ./rust; description = "Rust development environment"; }; + + zip = { + path = ./zig; + description = "Zig development environment"; + }; }; }; } diff --git a/gleam/.envrc b/gleam/.envrc new file mode 100644 index 0000000..a5dbbcb --- /dev/null +++ b/gleam/.envrc @@ -0,0 +1 @@ +use flake . diff --git a/gleam/flake.lock b/gleam/flake.lock new file mode 100644 index 0000000..04c22b1 --- /dev/null +++ b/gleam/flake.lock @@ -0,0 +1,42 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1656928814, + "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1657982260, + "narHash": "sha256-k9hwUbpgBmIipH2ZkRS5BpqLKbQYLiB0ewI+e9HHK0I=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2d2bf29c02bfd0fc0cafb613c6b49d3e6c0d6361", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/gleam/flake.nix b/gleam/flake.nix new file mode 100644 index 0000000..3a5511c --- /dev/null +++ b/gleam/flake.nix @@ -0,0 +1,30 @@ +{ + description = "A Nix-flake-based Gleam development environment"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + gleamPkg = pkgs.gleam; + + inherit (pkgs) mkShell; + in { + devShells = { + default = pkgs.mkShell { + nativeBuildInputs = [ + gleamPkg + ]; + + shellHook = '' + ${gleamPkg}/bin/gleam --version + ''; + }; + }; + } + ); +} diff --git a/go1.17/.envrc b/go1.17/.envrc index 03c6004..a5dbbcb 100644 --- a/go1.17/.envrc +++ b/go1.17/.envrc @@ -1,4 +1 @@ -if ! has nix_direnv_version || ! nix_direnv_version 2.1.1; then - source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.1.1/direnvrc" "sha256-b6qJ4r34rbE23yWjMqbmu3ia2z4b2wIlZUksBke/ol0=" -fi use flake . diff --git a/go1.17/.gitignore b/go1.17/.gitignore deleted file mode 100644 index 9b42106..0000000 --- a/go1.17/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.direnv/ diff --git a/go1.17/flake.nix b/go1.17/flake.nix index 7454483..3d41bbb 100644 --- a/go1.17/flake.nix +++ b/go1.17/flake.nix @@ -1,5 +1,5 @@ { - description = "Go 1.17 development environment"; + description = "A Nix-flake-based Go 1.17 development environment"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs"; @@ -11,6 +11,8 @@ let pkgs = import nixpkgs { inherit system; }; goPkg = pkgs.go_1_17; + + inherit (pkgs) mkShellNoCC; in { apps.default = { type = "app"; @@ -18,7 +20,7 @@ }; devShells = { - default = pkgs.mkShellNoCC { + default = mkShellNoCC { buildInputs = with pkgs; [ # go 1.17.1 goPkg @@ -40,8 +42,7 @@ ]; shellHook = '' - echo "Entering Go env" - echo "Running `${goPkg}/bin/go version`" + ${goPkg}/bin/go version ''; }; }; diff --git a/go1.18/.envrc b/go1.18/.envrc index 03c6004..a5dbbcb 100644 --- a/go1.18/.envrc +++ b/go1.18/.envrc @@ -1,4 +1 @@ -if ! has nix_direnv_version || ! nix_direnv_version 2.1.1; then - source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.1.1/direnvrc" "sha256-b6qJ4r34rbE23yWjMqbmu3ia2z4b2wIlZUksBke/ol0=" -fi use flake . diff --git a/go1.18/.gitignore b/go1.18/.gitignore deleted file mode 100644 index 9b42106..0000000 --- a/go1.18/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.direnv/ diff --git a/go1.18/flake.nix b/go1.18/flake.nix index 0e78608..be62fe5 100644 --- a/go1.18/flake.nix +++ b/go1.18/flake.nix @@ -1,5 +1,5 @@ { - description = "Go 1.17 development environment"; + description = "A Nix-flake-based Go 1.18 development environment"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs"; @@ -11,6 +11,8 @@ let pkgs = import nixpkgs { inherit system; }; goPkg = pkgs.go_1_18; + + inherit (pkgs) mkShellNoCC; in { apps.default = { type = "app"; @@ -18,7 +20,7 @@ }; devShells = { - default = pkgs.mkShellNoCC { + default = mkShellNoCC { buildInputs = with pkgs; [ # go 1.18.3 goPkg @@ -40,8 +42,7 @@ ]; shellHook = '' - echo "Entering Go env" - echo "Running `${goPkg}/bin/go version`" + ${goPkg}/bin/go version ''; }; }; diff --git a/rust/.envrc b/rust/.envrc index 03c6004..a5dbbcb 100644 --- a/rust/.envrc +++ b/rust/.envrc @@ -1,4 +1 @@ -if ! has nix_direnv_version || ! nix_direnv_version 2.1.1; then - source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.1.1/direnvrc" "sha256-b6qJ4r34rbE23yWjMqbmu3ia2z4b2wIlZUksBke/ol0=" -fi use flake . diff --git a/rust/Cargo.lock b/rust/Cargo.lock deleted file mode 100644 index b21cc6a..0000000 --- a/rust/Cargo.lock +++ /dev/null @@ -1,7 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "rust" -version = "0.1.0" diff --git a/rust/Cargo.toml b/rust/Cargo.toml deleted file mode 100644 index 1ec6963..0000000 --- a/rust/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "rust" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] diff --git a/rust/flake.nix b/rust/flake.nix index d87baa3..018ad81 100644 --- a/rust/flake.nix +++ b/rust/flake.nix @@ -20,13 +20,14 @@ rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + inherit (pkgs) mkShell; inherit (pkgs.lib) optionals; inherit (pkgs.stdenv) isDarwin; in { packages.default = rust; devShells = { - default = pkgs.mkShell { + default = mkShell { nativeBuildInputs = [ rust pkgs.pkg-config diff --git a/rust/rust-toolchain.toml b/rust/rust-toolchain.toml index ead0271..05dfa32 100644 --- a/rust/rust-toolchain.toml +++ b/rust/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.61.0" +channel = "1.62.0" diff --git a/rust/src/main.rs b/rust/src/main.rs deleted file mode 100644 index e7a11a9..0000000 --- a/rust/src/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("Hello, world!"); -} diff --git a/zig/.envrc b/zig/.envrc new file mode 100644 index 0000000..a5dbbcb --- /dev/null +++ b/zig/.envrc @@ -0,0 +1 @@ +use flake . diff --git a/zig/flake.lock b/zig/flake.lock new file mode 100644 index 0000000..04c22b1 --- /dev/null +++ b/zig/flake.lock @@ -0,0 +1,42 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1656928814, + "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1657982260, + "narHash": "sha256-k9hwUbpgBmIipH2ZkRS5BpqLKbQYLiB0ewI+e9HHK0I=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2d2bf29c02bfd0fc0cafb613c6b49d3e6c0d6361", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/zig/flake.nix b/zig/flake.nix new file mode 100644 index 0000000..88c8ab3 --- /dev/null +++ b/zig/flake.nix @@ -0,0 +1,30 @@ +{ + description = "A Nix-flake-based Zig development environment"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + zigPkg = pkgs.zig; + + inherit (pkgs) mkShell; + in { + devShells = { + default = pkgs.mkShell { + nativeBuildInputs = [ + zigPkg + ]; + + shellHook = '' + echo "`${zigPkg}/bin/zig version`" + ''; + }; + }; + } + ); +}