Skip to content

Commit

Permalink
Merge pull request #21 from DeterminateSystems/fix-formatting
Browse files Browse the repository at this point in the history
Fix Nix formatting and add CI check
  • Loading branch information
edolstra authored Jun 28, 2024
2 parents 427266c + acc706f commit e2723a6
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 33 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# https://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
18 changes: 18 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Checks

on:
pull_request:
push:
branches: [main]

jobs:
flake-check:
runs-on: UbuntuLatest32Cores128G
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Check Nix formatting
run: |
nix shell "https://flakehub.com/f/NixOS/nixpkgs/*#nixpkgs-fmt" --command \
sh -c "git ls-files '*.nix' | xargs nixpkgs-fmt --check"
67 changes: 34 additions & 33 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
description = "Schemas for well-known Nix flake output types";

outputs = { self }:

let
mapAttrsToList = f: attrs: map (name: f name attrs.${name}) (builtins.attrNames attrs);

Expand Down Expand Up @@ -31,30 +30,34 @@
output);
};

appsSchema = {
version = 1;
doc = ''
The `apps` output provides commands available via `nix run`.
'';
inventory = output:
self.lib.mkChildren (builtins.mapAttrs (system: apps: let
forSystems = [system];
in {
inherit forSystems;
children =
builtins.mapAttrs (appName: app: {
inherit forSystems;
evalChecks.isValidApp =
app ? type
&& app.type == "app"
&& app ? program
&& builtins.isString app.program;
what = "app";
})
apps;
})
output);
};
appsSchema = {
version = 1;
doc = ''
The `apps` output provides commands available via `nix run`.
'';
inventory = output:
self.lib.mkChildren (builtins.mapAttrs
(system: apps:
let
forSystems = [ system ];
in
{
inherit forSystems;
children =
builtins.mapAttrs
(appName: app: {
inherit forSystems;
evalChecks.isValidApp =
app ? type
&& app.type == "app"
&& app ? program
&& builtins.isString app.program;
what = "app";
})
apps;
})
output);
};

packagesSchema = {
version = 1;
Expand All @@ -67,8 +70,8 @@
legacyPackagesSchema = {
version = 1;
doc = ''
The `legacyPackages` flake output is similar to `packages`, but it can be nested (i.e. contain attribute sets that contain more packages).
Since enumerating the packages in nested attribute sets is inefficient, `legacyPackages` should be avoided in favor of `packages`.
The `legacyPackages` flake output is similar to `packages` but different in that it can be nested and thus contain attribute sets that contain more packages.
Since enumerating packages in nested attribute sets can be inefficient, you should favor `packages` over `legacyPackages`.
'';
inventory = output:
self.lib.mkChildren (builtins.mapAttrs
Expand Down Expand Up @@ -134,14 +137,13 @@
formatterSchema = {
version = 1;
doc = ''
The `formatter` output specifies the package to use to format the
project.
The `formatter` output specifies the package to use to format the project.
'';
inventory = output:
self.lib.mkChildren (builtins.mapAttrs
(system: formatter:
{
forSystems = [system];
forSystems = [ system ];
shortDescription = formatter.meta.description or "";
derivation = formatter;
evalChecks.isDerivation = checkDerivation formatter;
Expand Down Expand Up @@ -176,8 +178,7 @@
hydraJobsSchema = {
version = 1;
doc = ''
The `hydraJobs` flake output defines derivations to be built
by the Hydra continuous integration system.
The `hydraJobs` flake output defines derivations to be built by the Hydra continuous integration system.
'';
allowIFD = false;
inventory = output:
Expand Down Expand Up @@ -257,7 +258,7 @@
inventory = output: self.lib.mkChildren (builtins.mapAttrs
(configName: this:
{
what = "Home manager configuration";
what = "Home Manager configuration";
derivation = this.activationPackage;
})
output);
Expand Down

0 comments on commit e2723a6

Please sign in to comment.