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

flake.nix: init #65

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
34 changes: 28 additions & 6 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ in
system ? builtins.currentSystem,
nixpkgs ? sources.nixpkgs,
treefmt-nix ? sources.treefmt-nix,
pkgs ? (
import nixpkgs {
inherit system;
config = { };
overlays = [ ];
}
),
}:
let
pkgs = import nixpkgs {
inherit system;
config = { };
overlays = [ ];
};
inherit (pkgs) lib;

runtimeExprPath = ./src/eval.nix;
Expand Down Expand Up @@ -79,10 +81,30 @@ let
}
);

# Fits in with `nix fmt`.
treefmtWrapper = treefmtEval.config.build.wrapper;

# Run regularly by CI and turned into a PR
autoPrUpdate =
let
updateScripts = {
flake = pkgs.writeShellApplication {
name = "update-flake";
runtimeInputs = with pkgs; [
git
nix
];
text = ''
echo "<details><summary>flake.nix changes</summary>"
# Needed because GitHub's rendering of the first body line breaks down otherwise
echo ""
echo '```'
cd "$1"
nix flake update 2>&1
echo '```'
echo "</details>"
'';
};
npins = pkgs.writeShellApplication {
name = "update-npins";
runtimeInputs = with pkgs; [ npins ];
Expand All @@ -91,7 +113,7 @@ let
# Needed because GitHub's rendering of the first body line breaks down otherwise
echo ""
echo '```'
npins update --directory "$1/npins" 2>&1
npins --directory "$1/npins" import-flake 2>&1
echo '```'
echo "</details>"
'';
Expand Down
47 changes: 47 additions & 0 deletions flake.lock

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

52 changes: 52 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
description = "nixpkgs-check-by-name: a linter for nixpkgs";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
};

outputs =
{
self,
nixpkgs,
treefmt-nix,
}:
let
# Until https://github.com/NixOS/nixpkgs/pull/295083 is accepted and merged.
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
eachSystem =
f:
nixpkgs.lib.genAttrs systems (
system:
f (
import ./default.nix {
inherit nixpkgs system treefmt-nix;
pkgs = nixpkgs.legacyPackages.${system};
}
)
);
in
{
packages = eachSystem (this: {
default = this.build;
});

devShells = eachSystem (this: {
default = this.shell;
});

checks = eachSystem (this: {
formatting = this.treefmt;
nixpkgs = this.nixpkgsCheck;
});

formatter = eachSystem (this: this.treefmtWrapper);
};
}
Loading