Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use numtide/blueprint instead of flake.parts #323

Merged
merged 3 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
brianmcgee marked this conversation as resolved.
Show resolved Hide resolved
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;
};
brianmcgee marked this conversation as resolved.
Show resolved Hide resolved
};
}
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