From 4ad1f4da7f58193c2893a826134c1322f07a6b9b Mon Sep 17 00:00:00 2001 From: yousiki Date: Thu, 21 Mar 2024 01:20:21 +0800 Subject: [PATCH] Add .envrc and update .gitignore and configs --- .envrc | 3 ++ .gitignore | 12 ++++- cells/common/configs.nix | 32 +++++++++++++ cells/common/devshells.nix | 34 +++++++++++++ cells/common/profiles/core.nix | 1 + cells/home/profiles/shell.nix | 7 +++ cells/nixos/hosts/hakase/default.nix | 1 + flake.lock | 72 ++++++++++++++++++++++++++++ flake.nix | 16 +++++-- 9 files changed, 174 insertions(+), 4 deletions(-) create mode 100644 .envrc create mode 100644 cells/common/configs.nix create mode 100644 cells/common/devshells.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3429c53 --- /dev/null +++ b/.envrc @@ -0,0 +1,3 @@ +source $(fetchurl https://raw.githubusercontent.com/paisano-nix/direnv/main/lib sha256-IgQhKK7UHL1AfCUntJO2KCaIDJQotRnK2qC4Daxk+wI=) + +use envreload //common/devshells/default diff --git a/.gitignore b/.gitignore index 25ed994..d36622d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,13 @@ /result /secrets/**/*.local +### Nixago ### +/.bin +/.cache +/.config +/.data +/.run + ### Emacs ### # -*- mode: gitignore; -*- *~ @@ -73,7 +80,7 @@ flycheck_*.el .AppleDouble .LSOverride -# Icon must end with two \r +# Icon must end with two Icon @@ -167,3 +174,6 @@ $RECYCLE.BIN/ # End of https://www.toptal.com/developers/gitignore/api/linux,macos,windows,vim,emacs,visualstudiocode + +# nixago: ignore-linked-files +/treefmt.toml \ No newline at end of file diff --git a/cells/common/configs.nix b/cells/common/configs.nix new file mode 100644 index 0000000..1b3ddcb --- /dev/null +++ b/cells/common/configs.nix @@ -0,0 +1,32 @@ +{ + inputs, + cell, +}: let + inherit (inputs) std nixpkgs; +in { + treefmt = std.lib.dev.mkNixago std.lib.cfg.treefmt { + data = { + global.excludes = [ + "nvfetcher/generated.*" + ]; + formatter = { + nix = { + command = "alejandra"; + includes = ["*.nix"]; + }; + prettier = { + command = "prettier"; + includes = [ + "*.json" + "*.md" + "*.yaml" + ]; + }; + }; + }; + packages = [ + inputs.nixpkgs.alejandra + inputs.nixpkgs.nodePackages.prettier + ]; + }; +} diff --git a/cells/common/devshells.nix b/cells/common/devshells.nix new file mode 100644 index 0000000..d88fc2e --- /dev/null +++ b/cells/common/devshells.nix @@ -0,0 +1,34 @@ +# project. It solves the vital problem of, "works on my machine." +{ + inputs, + cell, +}: { + default = inputs.std.lib.dev.mkShell { + name = "nichijou"; + + imports = [ + inputs.std.std.devshellProfiles.default + ]; + + packages = [ + (inputs.nixpkgs.extend inputs.nvfetcher.overlays.default).nvfetcher + ]; + + nixago = [ + cell.configs.treefmt + ]; + + commands = [ + { + name = "fetch"; + help = "Fetch latest sources with nvfetcher"; + command = "nvfetcher -o nvfetcher"; + } + { + name = "fmt"; + help = "Format code with treefmt"; + command = "treefmt"; + } + ]; + }; +} diff --git a/cells/common/profiles/core.nix b/cells/common/profiles/core.nix index 0be1281..bb7a3c1 100644 --- a/cells/common/profiles/core.nix +++ b/cells/common/profiles/core.nix @@ -56,6 +56,7 @@ in { alejandra cachix curl + direnv du-dust duf eza diff --git a/cells/home/profiles/shell.nix b/cells/home/profiles/shell.nix index 540bb19..93e4993 100644 --- a/cells/home/profiles/shell.nix +++ b/cells/home/profiles/shell.nix @@ -23,6 +23,13 @@ programs.btop.enable = true; + programs.direnv = { + enable = true; + enableBashIntegration = true; + enableZshIntegration = true; + nix-direnv.enable = true; + }; + programs.eza = { enable = true; enableBashIntegration = true; diff --git a/cells/nixos/hosts/hakase/default.nix b/cells/nixos/hosts/hakase/default.nix index 0ff1147..9e789d9 100644 --- a/cells/nixos/hosts/hakase/default.nix +++ b/cells/nixos/hosts/hakase/default.nix @@ -58,6 +58,7 @@ }; overlays = [ inputs.fenix.overlays.default + inputs.nvfetcher.overlays.default ]; }; }; diff --git a/flake.lock b/flake.lock index 5aa54c2..837492a 100644 --- a/flake.lock +++ b/flake.lock @@ -180,6 +180,22 @@ "type": "github" } }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-utils": { "locked": { "lastModified": 1659877975, @@ -288,6 +304,24 @@ "type": "github" } }, + "flake-utils_8": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "haumea": { "inputs": { "nixpkgs": [ @@ -609,6 +643,28 @@ "type": "github" } }, + "nvfetcher": { + "inputs": { + "flake-compat": "flake-compat_2", + "flake-utils": "flake-utils_8", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1708838575, + "narHash": "sha256-brhWjqJG+Yp0KGkF1LE7h0E86Z7OhDQJLo9qhWAmoYw=", + "owner": "berberman", + "repo": "nvfetcher", + "rev": "367e2eaa92d8f5133c2c5ac03a80c0cf25f301b8", + "type": "github" + }, + "original": { + "owner": "berberman", + "repo": "nvfetcher", + "type": "github" + } + }, "paisano": { "inputs": { "call-flake": "call-flake", @@ -668,6 +724,7 @@ "nixos-hardware": "nixos-hardware", "nixos-vscode-server": "nixos-vscode-server", "nixpkgs": "nixpkgs", + "nvfetcher": "nvfetcher", "std": [ "hive", "std" @@ -799,6 +856,21 @@ "type": "github" } }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "yants": { "inputs": { "nixpkgs": [ diff --git a/flake.nix b/flake.nix index 4e3d4e3..e18192f 100644 --- a/flake.nix +++ b/flake.nix @@ -24,6 +24,10 @@ cellBlocks = [ (std.blockTypes.functions "lib") + (std.blockTypes.nixago "configs") + + (std.blockTypes.devshells "devshells") + (std.blockTypes.functions "commonModules") (std.blockTypes.functions "commonProfiles") (std.blockTypes.functions "homeModules") @@ -35,9 +39,10 @@ ]; } { - nixosModules = hive.pick self [ - ["nixos" "nixosModules"] - ]; + devShells = hive.harvest self [["common" "devshells"]]; + } + { + nixosModules = hive.pick self [["nixos" "nixosModules"]]; } { nixosConfigurations = collect self "nixosConfigurations"; @@ -95,6 +100,11 @@ url = "github:nix-community/fenix"; inputs.nixpkgs.follows = "nixpkgs"; }; + + nvfetcher = { + url = "github:berberman/nvfetcher"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; nixConfig = rec {