Skip to content

Commit

Permalink
More schemas
Browse files Browse the repository at this point in the history
Also added the nix patched with schema support to the shell
  • Loading branch information
kip93 committed Oct 21, 2023
1 parent 47262af commit d47675a
Show file tree
Hide file tree
Showing 9 changed files with 223 additions and 16 deletions.
21 changes: 11 additions & 10 deletions flake.lock

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

21 changes: 18 additions & 3 deletions overlays/overrides/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

{ hydra, nix, ... } @ inputs:
{ hydra, nix, ... } @ _inputs:
final: prev:
let
# Avoid infinite recursion by renaming flakes
Expand All @@ -27,11 +27,26 @@ let
hydra_final = final // (hydra'.inputs.nix.overlays.default hydra_final prev);
# Get the relevant bits out of the provided overlays
inherit (hydra'.overlays.default hydra_final prev) hydra perlPackages;
inherit (nix'.overlays.default final prev) lowdown-nix nix;
inherit (nix'.overlays.default final prev) lowdown-nix nix nixStable nixUnstable;

in
{
# Expose the extracted packages into the overlay
inherit lowdown-nix nix perlPackages;
inherit lowdown-nix nix nixStable nixUnstable perlPackages;
nixVersions = with final; prev.nixVersions // {
schemas = nixSchemas;
};
hydra_unstable = hydra;

# Build a nix package that has flake schema support (see nix#8892)
nixSchemas = nix.overrideAttrs ({ patches ? [ ], ... }: {
patches = patches ++ [
(final.fetchpatch {
url = "https://github.com/NixOS/nix/pull/8892.diff";
hash = "sha256-NfBksfuW1RUWe3O9cyqdM+A4O9ZGvEWg8rfv+24BosA=";
excludes = [ "doc/manual/src/SUMMARY.md.in" "flake.nix" "flake.lock" ];
})
];
doCheck = false; # Schema tests still require internet connection
});
}
31 changes: 31 additions & 0 deletions schemas/apps/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This file is part of Nix++.
# Copyright (C) 2023 Leandro Emmanuel Reina Kiperman.
#
# Nix++ is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# Nix++ is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

{ ... } @ _inputs:
{
version = 1;
doc = ''
The `apps` flake output is a set of executables that can be run using `nix run`.
'';
inventory = output: {
children = builtins.mapAttrs
(system: apps: {
forSystems = [ system ];
children = builtins.mapAttrs (_: _: { what = "flake app"; }) apps;
})
output
;
};
}
4 changes: 2 additions & 2 deletions schemas/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
(self.lib.import.asSchemas' {
path = ./.;
apply = _: schema: schema inputs;
# TODO apps nixosModules packages templates
}) // {
inherit (flake-schemas.schemas)
devShells
checks
hydraJobs
# hydraJobs # Reimplemented to avoid nesting into cross compiled jobs
nixosConfigurations
nixosModules
overlays
# packages # We have a superset that also allows for cross-compilation
schemas
Expand Down
55 changes: 55 additions & 0 deletions schemas/hydraJobs/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This file is part of Nix++.
# Copyright (C) 2023 Leandro Emmanuel Reina Kiperman.
#
# Nix++ is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# Nix++ is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

{ nixpkgs, ... } @ _inputs:
{
version = 1;
doc = ''
The `hydraJobs` flake output defines derivations to be built by the Hydra
continuous integration system.
'';
inventory = output: {
children = builtins.mapAttrs
(_: category: {
children = builtins.mapAttrs
(name: jobset:
let
localSystem = builtins.head (nixpkgs.lib.splitString "." name);
crossSystem = nixpkgs.lib.removePrefix "${localSystem}." name;

in
{
forSystems = [ localSystem ];
children = builtins.mapAttrs
(_: job: {
what = "Hydra CI job (${
if localSystem == crossSystem then
"natively compiled on ${localSystem}"
else
"cross compiled on ${localSystem} for ${crossSystem}"
})";
derivation = job;
})
jobset
;
}
)
category
;
})
output
;
};
}
4 changes: 4 additions & 0 deletions schemas/lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ let
_apply = metadata: {
what = "Metadata for this flake";
} // recurse metadata [ "meta" ];
homepage._apply = _: {
what = "This flake's home page";
};
license._apply = _: {
what = "GPLv3+ license";
};
Expand All @@ -41,6 +44,7 @@ let
what = "Cross-compiled nixpkgs with overlays applied";
children = builtins.mapAttrs
(localSystem: crossPkgs: {
forSystems = [ localSystem ];
children = builtins.mapAttrs
(crossSystem: _: {
what = "nixpkgs (${
Expand Down
72 changes: 72 additions & 0 deletions schemas/packages/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# This file is part of Nix++.
# Copyright (C) 2023 Leandro Emmanuel Reina Kiperman.
#
# Nix++ is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# Nix++ is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

{ nixpkgs, self, ... } @ _inputs:
{
version = 1;
doc = ''
The `packages` flake output is a collection of packages that can be installed
using `nix profile install`.
'';
inventory = output: {
children = builtins.mapAttrs
(localSystem: packages: {
forSystems = [ localSystem ];
children = (builtins.mapAttrs
(_: derivation: {
what = "Derivation for (natively compiled on ${localSystem})";
inherit derivation;
})
(nixpkgs.lib.filterAttrs
(name: _:
(builtins.all (system: name != system) self.lib.supportedSystems)
&& (!nixpkgs.lib.hasPrefix "_" name)
)
packages
)
) // (builtins.listToAttrs (builtins.map
(crossSystem: {
name = crossSystem;
value = {
children = builtins.mapAttrs
(_: derivation: {
what = "Derivation (${
if localSystem == crossSystem then
"natively compiled on ${localSystem}"
else
"cross compiled on ${localSystem} for ${crossSystem}"
})";
inherit derivation;
})
(nixpkgs.lib.filterAttrs
(name: _: !nixpkgs.lib.hasPrefix "_" name)
packages.${crossSystem}.passthru
)
;
};
})
(builtins.filter
(name:
builtins.any (system: name == system)
self.lib.supportedSystems
)
(builtins.attrNames packages)
)
));
})
output
;
};
}
29 changes: 29 additions & 0 deletions schemas/templates/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This file is part of Nix++.
# Copyright (C) 2023 Leandro Emmanuel Reina Kiperman.
#
# Nix++ is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# Nix++ is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

{ ... } @ _inputs:
{
version = 1;
doc = ''
The `templates` flake output is used to provide ways to create new flakes using
`nix flake init`.
'';
inventory = output: {
children = builtins.mapAttrs
(_: _: { what = "flake template"; })
output
;
};
}
2 changes: 1 addition & 1 deletion shells/default/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# Basics
({ lib, pkgs, ... }: {
name = "Nix++";
packages = with pkgs; [ cacert coreutils nixVersions.unstable ];
packages = with pkgs; [ cacert coreutils nixVersions.schemas ];
enterShell = lib.mkBefore ''
EDITOR="''${EDITOR:-${npppkgs.vim-minimal}/bin/vim}" # Default to vim
export EDITOR
Expand Down

0 comments on commit d47675a

Please sign in to comment.