diff --git a/.envrc b/.envrc index 22bd8064..197c0d59 100644 --- a/.envrc +++ b/.envrc @@ -1,2 +1,3 @@ -use_nix +#!/bin/bash +use flake diff --git a/.github/workflows/ci-home.yml b/.github/workflows/ci-home.yml index 2a018670..fdc5ba3c 100644 --- a/.github/workflows/ci-home.yml +++ b/.github/workflows/ci-home.yml @@ -34,8 +34,6 @@ jobs: steps: - uses: DeterminateSystems/nix-installer-action@v4 - uses: DeterminateSystems/magic-nix-cache-action@v2 - - name: Print nixpkgs version - run: nix-instantiate --eval -E '(import {}).lib.version' - name: Register Nix Channels run: | nix-channel --add https://releases.nixos.org/nixpkgs/nixpkgs-23.11pre509044.3acb5c4264c4/nixexprs.tar.xz nixpkgs diff --git a/.github/workflows/ci-nix.yml b/.github/workflows/ci-nix.yml index 6405f93d..270dafa8 100644 --- a/.github/workflows/ci-nix.yml +++ b/.github/workflows/ci-nix.yml @@ -5,11 +5,13 @@ on: paths: - '.github/workflows/ci-nix.yml' - '*.nix' + - 'flake.*' - 'Makefile.toml' pull_request: paths: - '.github/workflows/ci-nix.yml' - '*.nix' + - 'flake.*' - 'Makefile.toml' schedule: # Every 10:42 JST @@ -25,5 +27,5 @@ jobs: - uses: actions/checkout@v3 - uses: DeterminateSystems/nix-installer-action@v4 - uses: DeterminateSystems/magic-nix-cache-action@v2 - - run: nix-shell --run 'echo This step should be done before any other "nix-shell" steps because of measuring Nix build time' - - run: nix-shell --run 'makers ci-dev' + - run: nix develop --command echo 'This step should be done before any other "nix develop" steps because of measuring Nix build time' + - run: nix develop --command makers ci-dev diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3a03a783..b5b2fa31 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,7 +1,7 @@ # Development 1. Install [Nix](https://nixos.org/) package manager -1. `nix-shell --command 'makers setup'` +1. `nix develop --command makers setup` - `direnv allow` may not work if you have not completed all the installation steps ## Note diff --git a/README.md b/README.md index 46ced2de..d74d9b0f 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Also known as [盆栽(bonsai)](https://en.wikipedia.org/wiki/Bonsai) 🌳 1. Install [Nix](https://nixos.org/) package manager 1. Install [home-manager](https://github.com/nix-community/home-manager) -1. `nix-shell --command 'makers apply'` +1. `nix develop --command makers apply` ## I don't know ??? - I have just installed OS, I am 🚼 diff --git a/default.nix b/default.nix deleted file mode 100644 index f189eb29..00000000 --- a/default.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ pkgs ? import - (fetchTarball - "https://releases.nixos.org/nixpkgs/nixpkgs-23.11pre509044.3acb5c4264c4/nixexprs.tar.xz") - { } -}: - -pkgs.mkShell { - buildInputs = with pkgs; - [ - # https://github.com/NixOS/nix/issues/730#issuecomment-162323824 - bashInteractive - - dprint - shellcheck - shfmt - nil - nixpkgs-fmt - gitleaks - cargo-make - typos - go_1_20 - - # To get sha256 around pkgs.fetchFromGitHub in CLI - nix-prefetch-git - jq - ]; -} diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..847f47f2 --- /dev/null +++ b/flake.lock @@ -0,0 +1,56 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "narHash": "sha256-BXtO36CWk7WnRJVsKBV0uZQ9VWfduKbfrutkYUxQGmg=", + "type": "tarball", + "url": "https://releases.nixos.org/nixpkgs/nixpkgs-23.11pre509044.3acb5c4264c4/nixexprs.tar.xz" + }, + "original": { + "type": "tarball", + "url": "https://releases.nixos.org/nixpkgs/nixpkgs-23.11pre509044.3acb5c4264c4/nixexprs.tar.xz" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..128fd240 --- /dev/null +++ b/flake.nix @@ -0,0 +1,43 @@ +{ + inputs = { + # Candidate channels + # - https://github.com/kachick/anylang-template/issues/17 + # - https://discourse.nixos.org/t/differences-between-nix-channels/13998 + # How to update the revision + # - `nix flake update --commit-lock-file` # https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake-update.html + # TODO: Refer a popular channel in another issues + # nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + nixpkgs.url = "https://releases.nixos.org/nixpkgs/nixpkgs-23.11pre509044.3acb5c4264c4/nixexprs.tar.xz"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + { + devShells.default = with pkgs; + mkShell { + buildInputs = [ + # https://github.com/NixOS/nix/issues/730#issuecomment-162323824 + bashInteractive + + dprint + shellcheck + shfmt + nil + nixpkgs-fmt + gitleaks + cargo-make + typos + go_1_20 + + # To get sha256 around pkgs.fetchFromGitHub in CLI + nix-prefetch-git + jq + ]; + }; + } + ); +}