commit acf1a071320554641479c1561d13fd7d58c239c2 Author: Callum Leslie Date: Wed Sep 10 11:29:31 2025 +0100 initial commit diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..af0cc93 --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +use flake diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dcf4056 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +release +.pre-commit-config.yaml +.direnv diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..0e9cef3 --- /dev/null +++ b/flake.lock @@ -0,0 +1,121 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1747046372, + "narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "git-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1757239681, + "narHash": "sha256-E9spYi9lxm2f1zWQLQ7xQt8Xs2nWgr1T4QM7ZjLFphM=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "ab82ab08d6bf74085bd328de2a8722c12d97bd9d", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "git-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1757034884, + "narHash": "sha256-PgLSZDBEWUHpfTRfFyklmiiLBE1i1aGCtz4eRA3POao=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ca77296380960cd497a765102eeb1356eb80fed0", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "git-hooks": "git-hooks", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1689347949, + "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", + "owner": "nix-systems", + "repo": "default-linux", + "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default-linux", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..4f64271 --- /dev/null +++ b/flake.nix @@ -0,0 +1,71 @@ +{ + description = "C's Nix Packages"; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + flake-utils = { + url = "github:numtide/flake-utils"; + inputs.systems.url = "github:nix-systems/default-linux"; + }; + + git-hooks = { + url = "github:cachix/git-hooks.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { + nixpkgs, + flake-utils, + git-hooks, + ... + }: + flake-utils.lib.eachDefaultSystem + (system: let + pkgs = nixpkgs.legacyPackages.${system}; + inherit (nixpkgs) lib; + scenics = import ./pkgs { + inherit pkgs lib; + }; + git-hook-check = git-hooks.lib.${system}.run { + src = ./.; + hooks = { + alejandra.enable = true; + deadnix.enable = true; + statix.enable = true; + flake-checker.enable = true; + + end-of-file-fixer.enable = true; + check-merge-conflicts.enable = true; + trim-trailing-whitespace.enable = true; + + actionlint.enable = true; + + check-yaml.enable = true; + check-toml.enable = false; + check-json.enable = false; + + typos.enable = true; + + shellcheck.enable = true; + shfmt.enable = true; + }; + }; + in { + packages = scenics; + + checks = { + git-hook = git-hook-check; + }; + + devShells.default = pkgs.mkShell { + inherit (git-hook-check) shellHook; + buildInputs = with pkgs; [nix-init alejandra]; + }; + + formatter = pkgs.alejandra; + }) + // { + overlays.default = import ./overlay.nix; + }; +} diff --git a/overlay.nix b/overlay.nix new file mode 100644 index 0000000..9e516fe --- /dev/null +++ b/overlay.nix @@ -0,0 +1,3 @@ +final: _: { + scenics = final.callPackages ./pkgs {}; +} diff --git a/pkgs/default.nix b/pkgs/default.nix new file mode 100644 index 0000000..40cb23d --- /dev/null +++ b/pkgs/default.nix @@ -0,0 +1,9 @@ +{ + pkgs, + lib, +}: +# ./default.nix gets included as default, so remove it from the final package set +builtins.removeAttrs (lib.packagesFromDirectoryRecursive { + inherit (pkgs) callPackage; + directory = ./.; +}) ["default"]