diff options
author | Alan Pearce | 2024-11-16 13:11:06 +0100 |
---|---|---|
committer | Alan Pearce | 2024-11-16 13:11:06 +0100 |
commit | 72018b5585e945aa51a3a557a641cce17cabaf26 (patch) | |
tree | 5dfaa8c99fba0cb233192097273931d7d148f7d7 | |
parent | cd04ffd199e989f233797d18013fe35380b0376d (diff) | |
download | website-72018b5585e945aa51a3a557a641cce17cabaf26.tar.lz website-72018b5585e945aa51a3a557a641cce17cabaf26.tar.zst website-72018b5585e945aa51a3a557a641cce17cabaf26.zip |
Switch back to flakes
-rw-r--r-- | ci.nix | 18 | ||||
-rw-r--r-- | default.nix | 21 | ||||
-rw-r--r-- | flake.lock | 169 | ||||
-rw-r--r-- | flake.nix | 61 | ||||
-rwxr-xr-x | justfile | 2 | ||||
-rw-r--r-- | npins/default.nix | 80 | ||||
-rw-r--r-- | npins/sources.json | 29 | ||||
-rw-r--r-- | shell.nix | 25 |
8 files changed, 231 insertions, 174 deletions
diff --git a/ci.nix b/ci.nix deleted file mode 100644 index 33b514d..0000000 --- a/ci.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ pkgs ? ( - let - sources = import ./npins; - in - import sources.nixpkgs { } - ) -}: -pkgs.mkShell { - packages = with pkgs; [ - go - templ - hyperlink - just - - ko - flyctl - ]; -} diff --git a/default.nix b/default.nix deleted file mode 100644 index 779ea74..0000000 --- a/default.nix +++ /dev/null @@ -1,21 +0,0 @@ -let - sources = import ./npins; - - pkgs = import sources.nixpkgs { }; - pre-commit-hooks = import sources.pre-commit-hooks; -in -{ - pre-commit-check = pre-commit-hooks.run { - src = ./.; - hooks = { - go-mod-tidy = { - enable = true; - name = "go-mod-tidy"; - description = "Run `go mod tidy`"; - types_or = [ "go" "go-mod" ]; - entry = "${pkgs.go}/bin/go mod tidy"; - pass_filenames = false; - }; - }; - }; -} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..7bd6573 --- /dev/null +++ b/flake.lock @@ -0,0 +1,169 @@ +{ + "nodes": { + "flake-compat": { + "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-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" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "pre-commit-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": 1731531548, + "narHash": "sha256-sz8/v17enkYmfpgeeuyzniGJU0QQBfmAjlemAUYhfy8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "24f0d4acd634792badd6470134c387a3b039dace", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1730741070, + "narHash": "sha256-edm8WG19kWozJ/GqyYx2VjW99EdhjKwbY3ZwdlPAAlo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d063c1dd113c91ab27959ba540c0d9753409edf3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1730768919, + "narHash": "sha256-8AKquNnnSaJRXZxc5YmF/WfmxiHX6MMZZasRP6RRQkE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a04d33c0c3f1a59a2c1cb0c6e34cd24500e5a1dc", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat_2", + "gitignore": "gitignore", + "nixpkgs": "nixpkgs_2", + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1731363552, + "narHash": "sha256-vFta1uHnD29VUY4HJOO/D6p6rxyObnf+InnSMT4jlMU=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "cd1af27aa85026ac759d5d3fccf650abe7e1bbf0", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks", + "utils": "utils" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "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" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..34f4360 --- /dev/null +++ b/flake.nix @@ -0,0 +1,61 @@ +{ + description = "My website, alanpearce.eu"; + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + inputs.utils.url = "github:numtide/flake-utils"; + inputs.flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; + inputs.pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix"; + + outputs = { self, nixpkgs, utils, pre-commit-hooks, ... }: + utils.lib.eachDefaultSystem + (system: + let + pkgs = import nixpkgs { + inherit system; + }; + commonShellPackages = with pkgs; [ + go + templ + hyperlink + just + ko + flyctl + ]; + devPackages = with pkgs; [ + gopls + gotools + + systemfd + just + modd + ]; + in + { + devShells = { + ci = pkgs.mkShell { + packages = commonShellPackages; + }; + default = pkgs.mkShell { + inherit (self.checks.${system}.pre-commit-check) shellHook; + packages = devPackages ++ commonShellPackages; + }; + }; + checks = { + pre-commit-check = pre-commit-hooks.lib.${system}.run { + src = ./.; + hooks = { + go-mod-tidy = { + enable = true; + name = "go-mod-tidy"; + description = "Run `go mod tidy`"; + types_or = [ "go" "go-mod" ]; + entry = "${pkgs.go}/bin/go mod tidy"; + pass_filenames = false; + }; + }; + }; + }; + }); +} diff --git a/justfile b/justfile index 9c02f31..55401dd 100755 --- a/justfile +++ b/justfile @@ -19,7 +19,7 @@ check-links: hyperlink public --sources content update-all: - npins update + nix flake update go get -u all build: diff --git a/npins/default.nix b/npins/default.nix deleted file mode 100644 index 5e7d086..0000000 --- a/npins/default.nix +++ /dev/null @@ -1,80 +0,0 @@ -# Generated by npins. Do not modify; will be overwritten regularly -let - data = builtins.fromJSON (builtins.readFile ./sources.json); - version = data.version; - - mkSource = - spec: - assert spec ? type; - let - path = - if spec.type == "Git" then - mkGitSource spec - else if spec.type == "GitRelease" then - mkGitSource spec - else if spec.type == "PyPi" then - mkPyPiSource spec - else if spec.type == "Channel" then - mkChannelSource spec - else - builtins.throw "Unknown source type ${spec.type}"; - in - spec // { outPath = path; }; - - mkGitSource = - { - repository, - revision, - url ? null, - hash, - branch ? null, - ... - }: - assert repository ? type; - # At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository - # In the latter case, there we will always be an url to the tarball - if url != null then - (builtins.fetchTarball { - inherit url; - sha256 = hash; # FIXME: check nix version & use SRI hashes - }) - else - assert repository.type == "Git"; - let - urlToName = - url: rev: - let - matched = builtins.match "^.*/([^/]*)(\\.git)?$" repository.url; - - short = builtins.substring 0 7 rev; - - appendShort = if (builtins.match "[a-f0-9]*" rev) != null then "-${short}" else ""; - in - "${if matched == null then "source" else builtins.head matched}${appendShort}"; - name = urlToName repository.url revision; - in - builtins.fetchGit { - url = repository.url; - rev = revision; - inherit name; - # hash = hash; - }; - - mkPyPiSource = - { url, hash, ... }: - builtins.fetchurl { - inherit url; - sha256 = hash; - }; - - mkChannelSource = - { url, hash, ... }: - builtins.fetchTarball { - inherit url; - sha256 = hash; - }; -in -if version == 3 then - builtins.mapAttrs (_: mkSource) data.pins -else - throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`" diff --git a/npins/sources.json b/npins/sources.json deleted file mode 100644 index 7c490a4..0000000 --- a/npins/sources.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "pins": { - "nixpkgs": { - "type": "Git", - "repository": { - "type": "GitHub", - "owner": "NixOS", - "repo": "nixpkgs" - }, - "branch": "nixpkgs-unstable", - "revision": "dfffb2e7a52d29a0ef8e21ec8a0f30487b227f1a", - "url": "https://github.com/NixOS/nixpkgs/archive/dfffb2e7a52d29a0ef8e21ec8a0f30487b227f1a.tar.gz", - "hash": "0rp3nkvfwzbsn2rmc8kw0yh1gn0sfw03kzr3ks4smgpal813w67m" - }, - "pre-commit-hooks": { - "type": "Git", - "repository": { - "type": "GitHub", - "owner": "cachix", - "repo": "pre-commit-hooks.nix" - }, - "branch": "master", - "revision": "3c3e88f0f544d6bb54329832616af7eb971b6be6", - "url": "https://github.com/cachix/pre-commit-hooks.nix/archive/3c3e88f0f544d6bb54329832616af7eb971b6be6.tar.gz", - "hash": "04pwjz423iq2nkazkys905gvsm5j39722ngavrnx42b8msr5k555" - } - }, - "version": 3 -} \ No newline at end of file diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 4b62685..0000000 --- a/shell.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ pkgs ? ( - let - sources = import ./npins; - in - import sources.nixpkgs { } - ) -}: -let - inherit (import ./.) pre-commit-check; -in -pkgs.mkShell { - inherit (pre-commit-check) shellHook; - packages = with pkgs; [ - go - npins - gopls - go-licenses - gotools - templ - hyperlink - systemfd - just - modd - ]; -} |