Skip to content

Commit

Permalink
Merge pull request #323 from numtide/feat/blueprint
Browse files Browse the repository at this point in the history
feat: use numtide/blueprint instead of flake.parts
  • Loading branch information
mergify[bot] authored Jun 30, 2024
2 parents 492083b + ff5380a commit ab9f831
Show file tree
Hide file tree
Showing 19 changed files with 283 additions and 361 deletions.
4 changes: 4 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
dotenv

if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4="
fi

watch_file flake.nix
watch_file nix/devshell.nix

use flake
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Build the docs
id: build
run: |
nix build .#docs
nix build .#treefmt-docs
echo "result=$(readlink ./result)" >> $GITHUB_OUTPUT
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
Expand Down
8 changes: 7 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
{system ? builtins.currentSystem}: let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);

inherit (lock.nodes.flake-compat.locked) owner repo rev narHash;
inherit
(lock.nodes.flake-compat.locked)
owner
repo
rev
narHash
;

flake-compat = fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz";
Expand Down
60 changes: 38 additions & 22 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 27 additions & 27 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,13 @@
description = "Treefmt: once CLI to format your repo";

nixConfig = {
extra-substituters = [
"https://numtide.cachix.org"
];
extra-trusted-public-keys = [
"numtide.cachix.org-1:2ps1kLBUWjxIneOy1Ik6cQjb41X0iXVXeHigGmycPPE="
];
extra-substituters = ["https://numtide.cachix.org"];
extra-trusted-public-keys = ["numtide.cachix.org-1:2ps1kLBUWjxIneOy1Ik6cQjb41X0iXVXeHigGmycPPE="];
};

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
treefmt-nix = {
url = "github:numtide/treefmt-nix";
blueprint = {
url = "github:numtide/blueprint";
inputs.nixpkgs.follows = "nixpkgs";
};
devshell = {
Expand All @@ -29,28 +20,37 @@
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "devshell/flake-utils";
};
nix-filter.url = "github:numtide/nix-filter";
flake-compat.url = "github:nix-community/flake-compat";
nix-filter.url = "github:numtide/nix-filter";
nix-github-actions = {
url = "github:nix-community/nix-github-actions";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake
{
outputs = inputs: let
inherit (inputs.nixpkgs) lib;
in
inputs.blueprint {
inherit inputs;
prefix = "nix/";
nixpkgs.config = {
allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) ["terraform"];
};
}
{
imports = [
./nix
];
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
// {
githubActions = inputs.nix-github-actions.lib.mkGithubMatrix {
checks =
lib.getAttrs [
"x86_64-linux"
"x86_64-darwin"
]
inputs.self.checks;
};
};
}
16 changes: 0 additions & 16 deletions nix/checks.nix

This file was deleted.

10 changes: 0 additions & 10 deletions nix/default.nix

This file was deleted.

112 changes: 58 additions & 54 deletions nix/devshell.nix
Original file line number Diff line number Diff line change
@@ -1,59 +1,63 @@
{inputs, ...}: {
imports = [
inputs.devshell.flakeModule
{
pkgs,
perSystem,
...
}:
perSystem.devshell.mkShell {
env = [
{
name = "GOROOT";
value = pkgs.go + "/share/go";
}
];

config.perSystem = {
lib,
pkgs,
config,
...
}: let
inherit (pkgs.stdenv) isLinux isDarwin;
in {
config.devshells.default = {
env = [
{
name = "GOROOT";
value = pkgs.go + "/share/go";
}
{
name = "LD_LIBRARY_PATH";
value = "$DEVSHELL_DIR/lib";
}
];
packages = pkgs.lib.mkMerge [
(with pkgs; [
# golang
go
goreleaser
golangci-lint
delve
pprof
graphviz

packages = lib.mkMerge [
(with pkgs; [
# golang
go
goreleaser
golangci-lint
delve
pprof
graphviz
])
# platform dependent CGO dependencies
(lib.mkIf isLinux [
pkgs.gcc
])
(lib.mkIf isDarwin [
pkgs.darwin.cctools
])
# include formatters for development and testing
(import ./formatters.nix pkgs)
];
# docs
nodejs
])
# include formatters for development and testing
(import ./packages/treefmt/formatters.nix pkgs)
];

commands = [
{
category = "development";
package = pkgs.gomod2nix;
}
{
category = "development";
package = pkgs.enumer;
}
];
};
};
commands = [
{package = perSystem.gomod2nix.default;}
{
name = "docs:dev";
help = "serve docs for local development";
command = "cd $PRJ_ROOT/docs && npm ci && npm run dev";
}
{
name = "docs:build";
help = "create a production build of docs";
command = "cd $PRJ_ROOT/docs && npm ci && npm run build";
}
{
name = "docs:preview";
help = "preview a production build of docs";
command = "cd $PRJ_ROOT/docs && npm ci && npm run preview";
}
{
help = "generate terminal gifs";
package = pkgs.writeShellApplication {
name = "vhs";
runtimeInputs =
[
perSystem.self.treefmt
pkgs.rsync
pkgs.vhs
]
++ (import ./packages/treefmt/formatters.nix pkgs);
text = ''vhs "$@"'';
};
}
];
}
Loading

0 comments on commit ab9f831

Please sign in to comment.