forked from lix-project/nixos-module
Compare commits
110 commits
chase-fixe
...
main
Author | SHA1 | Date | |
---|---|---|---|
jade | 691193879d | ||
jade | fd186f535a | ||
Fabián Heredia Montiel | 81d9ff97c9 | ||
jade | 7dd3d652a3 | ||
jade | ca0cc16273 | ||
jade | bb51b2d161 | ||
Fabián Heredia Montiel | b3457b78ac | ||
jade | b0e6f35950 | ||
jade | daeb420858 | ||
Morgan Helton | 0dda988746 | ||
eldritch horrors | 353b25f0b6 | ||
jade | cecf70b775 | ||
jade | 542fb09131 | ||
jade | a0427505de | ||
jade | 1c291723b9 | ||
jade | e350380d72 | ||
jade | 624aaf9af1 | ||
jade | 550352df73 | ||
jade | 533223d8ee | ||
jade | 8d462dfd9d | ||
jade | de3c854615 | ||
jade | 03d62d5a74 | ||
crop | 05c6934e6b | ||
jade | d70318fb94 | ||
jade | 587812bdb5 | ||
eldritch horrors | 5d9d94089f | ||
eldritch horrors | f6e6871f38 | ||
jade | 909e593ae9 | ||
jade | 376ecb8038 | ||
jade | b64814c8c1 | ||
jade | 4e25f1ab68 | ||
jade | b4b38e6b5f | ||
jade | 38f31ee7c1 | ||
jade | 12b457c433 | ||
jade | 18fa4a89e2 | ||
jade | 6cd2d62a21 | ||
puck | 53d713eb48 | ||
puck | 36dbb9dbfb | ||
jade | fbc1c1c4da | ||
julia | 0c38126b49 | ||
puck | 7e8a5498db | ||
raito | 87b7b7e4bd | ||
jade | c8ab1e79ba | ||
jade | d15ff50703 | ||
Patrick Jackson | 5ef5fe6a67 | ||
Patrick Jackson | e09758962c | ||
jade | aaf759cd93 | ||
jade | 72060dfb08 | ||
Lunaphied | 10e849bdce | ||
raito | d4587ea6a6 | ||
raito | ef84a1e4b3 | ||
raito | 0bb33a2305 | ||
Qyriad | 4cf3e403e4 | ||
raito | 999cc24eca | ||
mei (ckie) | 9837ede4bd | ||
jade | e31baf5768 | ||
jade | 491e0f076f | ||
jade | 71df0f4a4a | ||
jade | 792119f425 | ||
Ilya K | 2148106d19 | ||
jade | cf119933da | ||
jade | 1d636fd90a | ||
jade | 7267c72d32 | ||
jade | 0428921238 | ||
jade | ddefc70e3d | ||
jade | 04186bcae3 | ||
Qyriad | d47d5dca07 | ||
Qyriad | 8c2d5ca8bc | ||
eldritch horrors | 532c44fa43 | ||
eldritch horrors | 23da6e1d0a | ||
Qyriad | 262c2b479d | ||
jade | d66013efdf | ||
jade | 9f7a36f023 | ||
Qyriad | a681f1cd49 | ||
Qyriad | 061640f9b2 | ||
Ilya K | 3e61e2aa24 | ||
jade | 8890cba994 | ||
Qyriad | 9b208d0d27 | ||
jade | 8937cebb4f | ||
Lunaphied | d1d43e601c | ||
jade | 4c47db0949 | ||
jade | 49fcc127f8 | ||
jade | cccea113fe | ||
jade | 1fee9f0e1f | ||
hexa | ddb978dcc9 | ||
eldritch horrors | 10fd7b4135 | ||
eldritch horrors | 49144e91d1 | ||
jade | b6e09b8191 | ||
hexa | 43eeb747b1 | ||
jade | 007b27add8 | ||
jade | 4a532feadb | ||
jade | f2d3bb0802 | ||
Qyriad | ceec87bc48 | ||
Emily Trau | e47e4c60f5 | ||
jade | 214f6ea5fc | ||
jade | d28160f571 | ||
jade | 9b5adef52d | ||
jade | 057c652b5d | ||
jade | cf5507a03d | ||
jade | 91055a3a46 | ||
jade | b2b26d073e | ||
31b491ddef | |||
baafefa6e4 | |||
raito | a50986cfc7 | ||
jade | 0ccb82f2b0 | ||
raito | 3ddd6e5e79 | ||
jade | 3fe47ad3f3 | ||
jade | bfceafae96 | ||
jade | 9db8932797 | ||
jade | 192dde3f06 |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
result
|
||||||
|
result-*
|
19
LICENSE
Normal file
19
LICENSE
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is furnished
|
||||||
|
to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice (including the next
|
||||||
|
paragraph) shall be included in all copies or substantial portions of the
|
||||||
|
Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
||||||
|
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||||
|
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
79
README.md
Normal file
79
README.md
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
# Lix NixOS module
|
||||||
|
|
||||||
|
See the [official installation guide][install-guide] for details on usage of
|
||||||
|
release versions.
|
||||||
|
|
||||||
|
[install-guide]: https://lix.systems/install/
|
||||||
|
|
||||||
|
See the [beta guide][beta-guide] for a setup guide on how to use HEAD:
|
||||||
|
|
||||||
|
[beta-guide]: https://wiki.lix.systems/link/1
|
||||||
|
|
||||||
|
## What does this do?
|
||||||
|
|
||||||
|
This is an overlay wrapped in a NixOS module that will replace CppNix with Lix
|
||||||
|
in nixpkgs. This is useful so that `nixos-rebuild`, `nix-direnv` and similar
|
||||||
|
will use Lix.
|
||||||
|
|
||||||
|
Optionally, it can build Lix from source.
|
||||||
|
|
||||||
|
## Versioning with Lix
|
||||||
|
|
||||||
|
The version of this overlay should match the major Lix version, *and* if
|
||||||
|
running HEAD, it should be the latest available version of the overlay.
|
||||||
|
Changes breaking the overlay are shamelessly done on HEAD, and we expect people
|
||||||
|
doing such changes to have prepared corresponding fix commits to make to the
|
||||||
|
overlay immediately after submitting their changes. If your build randomly
|
||||||
|
broke when updating HEAD, try updating your overlay.
|
||||||
|
|
||||||
|
The version of Lix pinned in this flake's `flake.lock` is a version of Lix
|
||||||
|
that is expected to work, however if running HEAD, it can be assumed to work
|
||||||
|
with HEAD as well if both `lix-nixos-module` and `lix` are the latest version.
|
||||||
|
|
||||||
|
## Common pitfalls
|
||||||
|
|
||||||
|
Various flake frameworks such as flake-parts and snowfall (and possibly Colmena
|
||||||
|
in the future if they do a similar optimization) manage overlays separately
|
||||||
|
from NixOS, since they provide `pkgs` pre-imported to NixOS. This saves a
|
||||||
|
couple of seconds of evaluation time and resources, but it means that the NixOS
|
||||||
|
option `nixpkgs.overlays` **is completely ignored** on these frameworks.
|
||||||
|
|
||||||
|
If you are using such a framework, add `overlays.default` to the overlays list
|
||||||
|
for said framework.
|
||||||
|
|
||||||
|
## Flake structure and usage
|
||||||
|
|
||||||
|
The flake here has two inputs of note:
|
||||||
|
- `nixpkgs`, *which is unused for most people*. It is purely used for `checks`
|
||||||
|
in developing `lix-nixos-module` itself.
|
||||||
|
|
||||||
|
The installation instructions make it `follows` to make `flake.lock` less
|
||||||
|
confusing, but it is nonetheless unused.
|
||||||
|
- `lix`, which determines the version of Lix to do source builds for, if doing
|
||||||
|
source builds.
|
||||||
|
|
||||||
|
These are the most relevant outputs for most people:
|
||||||
|
|
||||||
|
- `nixosModules.lixFromNixpkgs` - uses Lix from nixpkgs and installs the
|
||||||
|
overlay to use Lix on a NixOS system. This is only useful for a stable
|
||||||
|
version of Lix, and cannot be used for running HEAD.
|
||||||
|
- `nixosModules.default` - uses Lix from source and installs the overlay to use
|
||||||
|
Lix on a NixOS system.
|
||||||
|
- `overlays.lixFromNixpkgs` - overlay to use Lix from nixpkgs in place of Nix.
|
||||||
|
- `overlays.default` - overlay to use Lix from source in place of Nix.
|
||||||
|
|
||||||
|
## Non-flake usage
|
||||||
|
|
||||||
|
Import `module.nix` or `overlay.nix` as desired, with the arguments `lix`
|
||||||
|
(derivation-like attribute set with the Lix sources, or `null` to use Lix from
|
||||||
|
nixpkgs) and `versionSuffix` (optional string).
|
||||||
|
|
||||||
|
It's desirable to also include a `versionSuffix` like the following while
|
||||||
|
building HEAD from source, to have `nix --version` include date and commit
|
||||||
|
information. To get such metadata, it depends on which pinning system is in
|
||||||
|
use, but `builtins.fetchGit` will provide the necessary metadata for the
|
||||||
|
following to work:
|
||||||
|
|
||||||
|
```
|
||||||
|
versionSuffix = "pre${builtins.substring 0 8 lix.lastModifiedDate}-${lix.shortRev or lix.dirtyShortRev}";
|
||||||
|
```
|
45
flake.lock
45
flake.lock
|
@ -5,11 +5,11 @@
|
||||||
"systems": "systems"
|
"systems": "systems"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1709126324,
|
"lastModified": 1726560853,
|
||||||
"narHash": "sha256-q6EQdSeUZOG26WelxqkmR7kArjgWCdw5sfJVHPH/7j8=",
|
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "d465f4819400de7c8d874d50b982301f28a84605",
|
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -18,28 +18,42 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"flakey-profile": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1712898590,
|
||||||
|
"narHash": "sha256-FhGIEU93VHAChKEXx905TSiPZKga69bWl1VB37FK//I=",
|
||||||
|
"owner": "lf-",
|
||||||
|
"repo": "flakey-profile",
|
||||||
|
"rev": "243c903fd8eadc0f63d205665a92d4df91d42d9d",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "lf-",
|
||||||
|
"repo": "flakey-profile",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"lix": {
|
"lix": {
|
||||||
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1709811453,
|
"lastModified": 1731164513,
|
||||||
"narHash": "sha256-UOyTAdUAJv80w3s6rrgYB5tQjp43u5Zp2dlM94uud04=",
|
"narHash": "sha256-WnT6MpgrMKgqV2Rs+MfU88+KO+/njELPOtGoNhoX2oA=",
|
||||||
"ref": "refs/heads/main",
|
"rev": "b967f1d5fe9d1bf58e6159e9b426c5b341489397",
|
||||||
"rev": "8a268359b06471b463a8f3fc46c83a1fced8ab75",
|
"type": "tarball",
|
||||||
"revCount": 15077,
|
"url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/b967f1d5fe9d1bf58e6159e9b426c5b341489397.tar.gz?rev=b967f1d5fe9d1bf58e6159e9b426c5b341489397"
|
||||||
"type": "git",
|
|
||||||
"url": "ssh://gerrit.lix.systems:2022/lix"
|
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"type": "git",
|
"type": "tarball",
|
||||||
"url": "ssh://gerrit.lix.systems:2022/lix"
|
"url": "https://git.lix.systems/lix-project/lix/archive/main.tar.gz"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1709703039,
|
"lastModified": 1730785428,
|
||||||
"narHash": "sha256-6hqgQ8OK6gsMu1VtcGKBxKQInRLHtzulDo9Z5jxHEFY=",
|
"narHash": "sha256-Zwl8YgTVJTEum+L+0zVAWvXAGbWAuXHax3KzuejaDyo=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "9df3e30ce24fd28c7b3e2de0d986769db5d6225d",
|
"rev": "4aa36568d413aca0ea84a1684d2d46f55dbabad7",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -52,6 +66,7 @@
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
|
"flakey-profile": "flakey-profile",
|
||||||
"lix": "lix",
|
"lix": "lix",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
|
|
55
flake.nix
55
flake.nix
|
@ -1,25 +1,66 @@
|
||||||
{
|
{
|
||||||
# fixme: use the forgejo address
|
|
||||||
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
inputs.lix = {
|
inputs.lix = {
|
||||||
url = "git+ssh://gerrit.lix.systems:2022/lix";
|
url = "https://git.lix.systems/lix-project/lix/archive/main.tar.gz";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
inputs.flakey-profile.url = "github:lf-/flakey-profile";
|
||||||
|
|
||||||
outputs = { self, nixpkgs, lix, flake-utils }: {
|
outputs = inputs@{ self, nixpkgs, lix, flake-utils, flakey-profile, ... }:
|
||||||
nixosModules.default = import ./module.nix { inherit lix; };
|
let
|
||||||
overlays.default = import ./overlay.nix { inherit lix; };
|
lixVersionJson = builtins.fromJSON (builtins.readFile (lix + "/version.json"));
|
||||||
|
versionSuffix = nixpkgs.lib.optionalString (!lixVersionJson.official_release)
|
||||||
|
"-pre${builtins.substring 0 8 lix.lastModifiedDate}-${lix.shortRev or lix.dirtyShortRev}";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
inherit inputs;
|
||||||
|
nixosModules = {
|
||||||
|
# Use a locally built Lix
|
||||||
|
default = import ./module.nix { inherit lix versionSuffix; };
|
||||||
|
|
||||||
|
# Use Lix from nixpkgs
|
||||||
|
lixFromNixpkgs = import ./module.nix { lix = null; };
|
||||||
|
};
|
||||||
|
|
||||||
|
overlays = {
|
||||||
|
# Use a locally built Lix
|
||||||
|
default = import ./overlay.nix { inherit lix versionSuffix; };
|
||||||
|
|
||||||
|
# Use Lix from nixpkgs
|
||||||
|
lixFromNixpkgs = import ./overlay.nix { lix = null; };
|
||||||
|
};
|
||||||
} // flake-utils.lib.eachDefaultSystem (system:
|
} // flake-utils.lib.eachDefaultSystem (system:
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs {
|
pkgs = import nixpkgs {
|
||||||
inherit system;
|
inherit system;
|
||||||
overlays = [ self.overlays.default ];
|
overlays = [ self.overlays.default ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
linux64BitSystems = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"aarch64-linux"
|
||||||
|
];
|
||||||
|
|
||||||
|
inherit (pkgs) lib;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
packages.default = pkgs.nixVersions.nix_2_18;
|
packages = {
|
||||||
packages.nix-doc = pkgs.nix-doc;
|
default = pkgs.nix;
|
||||||
|
inherit (pkgs) nix-doc nix-eval-jobs;
|
||||||
|
};
|
||||||
|
|
||||||
|
packages.system-profile = import ./system-profile.nix { inherit pkgs flakey-profile; };
|
||||||
|
|
||||||
|
nixosTests = pkgs.recurseIntoAttrs (pkgs.callPackage ./test-nixos.nix { inherit pkgs; lix-module = self.nixosModules.default; });
|
||||||
|
|
||||||
|
checks = {
|
||||||
|
inherit (self.packages.${system}) default nix-eval-jobs;
|
||||||
|
inherit (pkgs) nixos-option;
|
||||||
|
} // lib.optionalAttrs (lib.elem system linux64BitSystems) {
|
||||||
|
# wrongMajor intentionally not included here since it is expected to fail
|
||||||
|
inherit (self.nixosTests.${system}) it-builds;
|
||||||
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{ lix }:
|
{ lix, versionSuffix ? "" }:
|
||||||
{ pkgs, config, ... }:
|
{ pkgs, config, ... }:
|
||||||
{
|
{
|
||||||
nixpkgs.overlays = [ (import ./overlay.nix { inherit lix; }) ];
|
nixpkgs.overlays = [ (import ./overlay.nix { inherit lix versionSuffix; }) ];
|
||||||
}
|
}
|
||||||
|
|
64
nix-doc/package.nix
Normal file
64
nix-doc/package.nix
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
# Temporary replacement of the nix-doc package with
|
||||||
|
# https://github.com/NixOS/nixpkgs/pull/296523 so that we can have working Lix
|
||||||
|
# with nix-doc on 23.11 and 24.05-pre
|
||||||
|
#
|
||||||
|
# Can be removed when that commit is in 23.11 and 24.05-pre, or 24.05 is
|
||||||
|
# released with the commit.
|
||||||
|
{ lib
|
||||||
|
, stdenv
|
||||||
|
, rustPlatform
|
||||||
|
, fetchFromGitHub
|
||||||
|
, boost
|
||||||
|
, nix
|
||||||
|
, pkg-config
|
||||||
|
# Whether to build the nix-doc plugin for Nix
|
||||||
|
, withPlugin ? true
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
packageFlags = [ "-p" "nix-doc" ] ++ lib.optionals withPlugin [ "-p" "nix-doc-plugin" ];
|
||||||
|
in
|
||||||
|
rustPlatform.buildRustPackage rec {
|
||||||
|
pname = "nix-doc";
|
||||||
|
version = "0.6.5";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
rev = "v${version}";
|
||||||
|
owner = "lf-";
|
||||||
|
repo = "nix-doc";
|
||||||
|
sha256 = "sha256-9cuNzq+CBA2jz0LkZb7lh/WISIlKklfovGBAbSo1Mgk=";
|
||||||
|
};
|
||||||
|
|
||||||
|
doCheck = true;
|
||||||
|
buildInputs = lib.optionals withPlugin [ boost nix ];
|
||||||
|
|
||||||
|
nativeBuildInputs = lib.optionals withPlugin [ pkg-config nix ];
|
||||||
|
|
||||||
|
cargoBuildFlags = packageFlags;
|
||||||
|
cargoTestFlags = packageFlags;
|
||||||
|
|
||||||
|
# Packaging support for making the nix-doc plugin load cleanly as a no-op on
|
||||||
|
# the wrong Nix version (disabling bindnow permits loading libraries
|
||||||
|
# requiring unavailable symbols if they are unreached)
|
||||||
|
hardeningDisable = lib.optionals withPlugin [ "bindnow" ];
|
||||||
|
# Due to a Rust bug, setting -Z relro-level to anything including "off" on
|
||||||
|
# macOS will cause link errors
|
||||||
|
env = lib.optionalAttrs (withPlugin && stdenv.isLinux) {
|
||||||
|
# nix-doc does not use nightly features, however, there is no other way to
|
||||||
|
# set relro-level
|
||||||
|
RUSTC_BOOTSTRAP = 1;
|
||||||
|
RUSTFLAGS = "-Z relro-level=partial";
|
||||||
|
};
|
||||||
|
|
||||||
|
cargoSha256 = "sha256-CHagzXTG9AfrFd3WmHanQ+YddMgmVxSuB8vK98A1Mlw=";
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = "An interactive Nix documentation tool";
|
||||||
|
longDescription = "An interactive Nix documentation tool providing a CLI for function search, a Nix plugin for docs in the REPL, and a ctags implementation for Nix script";
|
||||||
|
homepage = "https://github.com/lf-/nix-doc";
|
||||||
|
license = licenses.lgpl3Plus;
|
||||||
|
maintainers = [ maintainers.lf- ];
|
||||||
|
platforms = platforms.unix;
|
||||||
|
mainProgram = "nix-doc";
|
||||||
|
};
|
||||||
|
}
|
162
overlay.nix
162
overlay.nix
|
@ -1,47 +1,127 @@
|
||||||
{ lix }:
|
{ lix, versionSuffix ? "" }:
|
||||||
final: prev:
|
final: prev:
|
||||||
let
|
let
|
||||||
boehmgc-patched = ((final.boehmgc.override {
|
lixPackageFromSource = final.callPackage (lix + "/package.nix") ({
|
||||||
enableLargeConfig = true;
|
inherit versionSuffix;
|
||||||
}).overrideAttrs (o: {
|
stdenv = final.clangStdenv;
|
||||||
patches = (o.patches or [ ]) ++ [
|
});
|
||||||
# for clown reasons this version is newer than the one in lix, we should
|
|
||||||
# fix this and update our nixpkgs pin
|
|
||||||
(prev.path + "/pkgs/tools/package-management/nix/patches/boehmgc-coroutine-sp-fallback.patch")
|
|
||||||
|
|
||||||
# https://github.com/ivmai/bdwgc/pull/586
|
# These packages should receive CppNix since they may link to it or otherwise
|
||||||
(lix + "/boehmgc-traceable_allocator-public.diff")
|
# cause problems (or even just silly mass-rebuilds) if we give them Lix
|
||||||
|
overridelist_upstream = [
|
||||||
|
"attic-client"
|
||||||
|
"devenv"
|
||||||
|
"nix-du"
|
||||||
|
"nix-init"
|
||||||
|
"nix-prefetch-git"
|
||||||
|
"nixos-option"
|
||||||
|
"nurl"
|
||||||
|
"prefetch-yarn-deps" # force these onto upstream so we are not regularly rebuilding electron
|
||||||
];
|
];
|
||||||
})
|
|
||||||
|
inherit (prev) lib;
|
||||||
|
|
||||||
|
csi = builtins.fromJSON ''"\u001b"'';
|
||||||
|
orange = "${csi}[35;1m";
|
||||||
|
normal = "${csi}[0m";
|
||||||
|
warning = ''
|
||||||
|
${orange}warning${normal}: You have the lix overlay included into a nixpkgs import twice,
|
||||||
|
perhaps due to the NixOS module being included twice, or because of using
|
||||||
|
pkgs.nixos and also including it in imports, or perhaps some unknown
|
||||||
|
machinations of a complicated flake library.
|
||||||
|
This is completely harmless since we have no-op'd the second one if you are
|
||||||
|
seeing this message, but it would be a small style improvement to fix
|
||||||
|
it :)
|
||||||
|
P.S. If you had some hack to fix nixos-option build failures in your
|
||||||
|
configuration, that was caused by including an older version of the lix
|
||||||
|
overlay twice, which is now mitigated if you see this message, so you can
|
||||||
|
delete that.
|
||||||
|
P.P.S. This Lix has super catgirl powers.
|
||||||
|
'';
|
||||||
|
wrongMajorWarning = ''
|
||||||
|
${orange}warning${normal}: This Lix NixOS module is being built against a Lix with a
|
||||||
|
major version (got ${lixPackageToUse.version}) other than the one the
|
||||||
|
module was designed for (expecting ${supportedLixMajor}). Some downstream
|
||||||
|
packages like nix-eval-jobs may be broken by this. Consider using a
|
||||||
|
matching version of the Lix NixOS module to the version of Lix you are
|
||||||
|
using.
|
||||||
|
'';
|
||||||
|
|
||||||
|
maybeWarnDuplicate = x: if final.lix-overlay-present > 1 then builtins.trace warning x else x;
|
||||||
|
|
||||||
|
versionJson = builtins.fromJSON (builtins.readFile ./version.json);
|
||||||
|
supportedLixMajor = lib.versions.majorMinor versionJson.version;
|
||||||
|
lixPackageToUse = if lix != null then lixPackageFromSource else prev.lix;
|
||||||
|
# Especially if using Lix from nixpkgs, it is plausible that the overlay
|
||||||
|
# could be used against the wrong Lix major version and cause confusing build
|
||||||
|
# errors. This is a simple safeguard to put in at least something that might be seen.
|
||||||
|
maybeWarnWrongMajor = x: if !(lib.hasPrefix supportedLixMajor lixPackageToUse.version) then builtins.trace wrongMajorWarning x else x;
|
||||||
|
|
||||||
|
# It is not enough to *just* throw whatever the default nix version is at
|
||||||
|
# anything in the "don't give lix" list, we have to *also* ensure that we
|
||||||
|
# give whatever upstream version as specified in the callPackage invocation.
|
||||||
|
#
|
||||||
|
# Unfortunately I don't think there is any actual way to directly query that,
|
||||||
|
# so we instead do something extremely evil and guess which version it
|
||||||
|
# probably was. This code is not generalizable to arbitrary derivations, so
|
||||||
|
# it will hopefully not make us cry, at least.
|
||||||
|
useCppNixOverlay =
|
||||||
|
lib.genAttrs overridelist_upstream (
|
||||||
|
name:
|
||||||
|
if (lib.functionArgs prev.${name}.override ? "nix") then
|
||||||
|
let
|
||||||
|
# Get the two common inputs of a derivation/package.
|
||||||
|
inputs = prev.${name}.buildInputs ++ prev.${name}.nativeBuildInputs;
|
||||||
|
nixDependency = lib.findFirst
|
||||||
|
(drv: (drv.pname or "") == "nix")
|
||||||
|
final.nixVersions.stable_upstream # default to stable nix if nix is not an input
|
||||||
|
inputs;
|
||||||
|
nixMajor = lib.versions.major (nixDependency.version or "");
|
||||||
|
nixMinor = lib.versions.minor (nixDependency.version or "");
|
||||||
|
nixAttr = "nix_${nixMajor}_${nixMinor}";
|
||||||
|
finalNix = final.nixVersions.${nixAttr};
|
||||||
|
in
|
||||||
|
prev.${name}.override {
|
||||||
|
nix = finalNix;
|
||||||
|
}
|
||||||
|
else prev.${name}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
overlay = useCppNixOverlay // {
|
||||||
|
lix-overlay-present = 1;
|
||||||
|
# used for things that one wouldn't necessarily want to update, but we
|
||||||
|
# nevertheless shove it in the overlay and fixed-point it in case one *does*
|
||||||
|
# want to do that.
|
||||||
|
lix-sources = import ./pins.nix;
|
||||||
|
|
||||||
|
lix = maybeWarnWrongMajor (maybeWarnDuplicate lixPackageToUse);
|
||||||
|
|
||||||
|
nixVersions = prev.nixVersions // {
|
||||||
|
stable = final.lix;
|
||||||
|
stable_upstream = prev.nixVersions.stable;
|
||||||
|
};
|
||||||
|
|
||||||
|
nix-eval-jobs = (prev.nix-eval-jobs.override {
|
||||||
|
# lix
|
||||||
|
nix = final.lix;
|
||||||
|
}).overrideAttrs (old:
|
||||||
|
let src = final.lix-sources.nix-eval-jobs;
|
||||||
|
in {
|
||||||
|
version = "2.92.0-lix-${builtins.substring 0 7 src.rev}";
|
||||||
|
|
||||||
|
# FIXME: should this be patches instead?
|
||||||
|
inherit src;
|
||||||
|
|
||||||
|
mesonBuildType = "debugoptimized";
|
||||||
|
|
||||||
|
ninjaFlags = old.ninjaFlags or [ ] ++ [ "-v" ];
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
nix-doc = prev.callPackage ./nix-doc/package.nix { withPlugin = false; };
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
# Make the overlay idempotent, since flakes passing nixos modules around by
|
||||||
nixVersions = prev.nixVersions // rec {
|
# value and many other things make it way too easy to include the overlay
|
||||||
# FIXME: do something less scuffed
|
# twice
|
||||||
nix_2_18 = (prev.nixVersions.nix_2_18.override { boehmgc = boehmgc-patched; }).overrideAttrs (old: {
|
if (prev ? lix-overlay-present) then { lix-overlay-present = 2; } else overlay
|
||||||
src = lix;
|
|
||||||
version = "2.18.3-lix";
|
|
||||||
VERSION_SUFFIX = "-lix";
|
|
||||||
|
|
||||||
patches = [ ];
|
|
||||||
});
|
|
||||||
stable = nix_2_18;
|
|
||||||
nix_2_18_upstream = prev.nixVersions.nix_2_18;
|
|
||||||
};
|
|
||||||
|
|
||||||
# force these onto upstream so we are not regularly rebuilding electron
|
|
||||||
prefetch-yarn-deps = prev.prefetch-yarn-deps.override {
|
|
||||||
nix = final.nixVersions.nix_2_18_upstream;
|
|
||||||
};
|
|
||||||
prefetch-npm-deps = prev.prefetch-npm-deps.override {
|
|
||||||
nix = final.nixVersions.nix_2_18_upstream;
|
|
||||||
};
|
|
||||||
nix-prefetch-git = prev.nix-prefetch-git.override {
|
|
||||||
nix = final.nixVersions.nix_2_18_upstream;
|
|
||||||
};
|
|
||||||
|
|
||||||
nix-doc = prev.nix-doc.overrideAttrs (old: {
|
|
||||||
# for the purposes of nix C++ API for nix-doc, lix is Nix 2.20
|
|
||||||
NIX_CFLAGS_COMPILE = [ "-DNIX_2_20_0" ];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
1
pins.json
Normal file
1
pins.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"nix-eval-jobs": {"kind": "tarball", "rev": "57ddb99e781d19704f8a84036f9890e6ca554c41", "nar_hash": "sha256-9qkRZFTgbMonlBaLqL+OW6iiHLWXuBJlThISMhwQuGg=", "locked_url": "https://git.lix.systems/api/v1/repos/lix-project/nix-eval-jobs/archive/57ddb99e781d19704f8a84036f9890e6ca554c41.tar.gz?rev=57ddb99e781d19704f8a84036f9890e6ca554c41", "url": "https://git.lix.systems/lix-project/nix-eval-jobs/archive/main.tar.gz"}}
|
26
pins.nix
Normal file
26
pins.nix
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
# this is a custom pinning tool, written because npins doesn't have narHash
|
||||||
|
# compatible output for git inputs, and also doesn't support the Nix immutable
|
||||||
|
# tarball protocol
|
||||||
|
let
|
||||||
|
pins = builtins.fromJSON (builtins.readFile ./pins.json);
|
||||||
|
fetchPin = args@{ kind, ... }:
|
||||||
|
if kind == "git" then
|
||||||
|
builtins.fetchGit
|
||||||
|
{
|
||||||
|
name = "source";
|
||||||
|
url = args.url;
|
||||||
|
ref = args.ref;
|
||||||
|
rev = args.rev;
|
||||||
|
narHash = args.nar_hash;
|
||||||
|
}
|
||||||
|
else if kind == "tarball" then
|
||||||
|
args // {
|
||||||
|
outPath = builtins.fetchTarball {
|
||||||
|
name = "source";
|
||||||
|
url = args.locked_url;
|
||||||
|
sha256 = args.nar_hash;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else builtins.throw "unsupported input type ${kind}";
|
||||||
|
in
|
||||||
|
builtins.mapAttrs (_: fetchPin) pins
|
10
system-profile.nix
Normal file
10
system-profile.nix
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{ pkgs, flakey-profile }:
|
||||||
|
flakey-profile.lib.mkProfile {
|
||||||
|
inherit pkgs;
|
||||||
|
paths = with pkgs; [
|
||||||
|
cacert
|
||||||
|
nix
|
||||||
|
];
|
||||||
|
name = "system-profile";
|
||||||
|
extraSwitchArgs = [ "--profile" "/nix/var/nix/profiles/default" ];
|
||||||
|
}
|
32
test-nixos.nix
Normal file
32
test-nixos.nix
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
{ pkgs, nixos, lix-module }:
|
||||||
|
let
|
||||||
|
pkgs' = import pkgs.path {
|
||||||
|
inherit (pkgs) system;
|
||||||
|
};
|
||||||
|
configs = {
|
||||||
|
it-builds = nixos ({ ... }: {
|
||||||
|
imports = [ lix-module ];
|
||||||
|
documentation.enable = false;
|
||||||
|
fileSystems."/".device = "ignore-root-device";
|
||||||
|
boot.loader.grub.enable = false;
|
||||||
|
system.stateVersion = "24.05";
|
||||||
|
});
|
||||||
|
|
||||||
|
# Intentionally provoke the wrong major version.
|
||||||
|
# Does assume that the module is one major ahead of the release; the main
|
||||||
|
# purpose here is a manual testing fixture.
|
||||||
|
wrongMajor = pkgs'.nixos ({ ... }: {
|
||||||
|
imports = [ (import ./module.nix { lix = null; }) ];
|
||||||
|
documentation.enable = false;
|
||||||
|
fileSystems."/".device = "ignore-root-device";
|
||||||
|
boot.loader.grub.enable = false;
|
||||||
|
system.stateVersion = "24.05";
|
||||||
|
});
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
inherit configs;
|
||||||
|
|
||||||
|
it-builds = configs.it-builds.config.system.build.toplevel;
|
||||||
|
wrongMajor = configs.wrongMajor.config.system.build.toplevel;
|
||||||
|
}
|
165
update_pins.py
Executable file
165
update_pins.py
Executable file
|
@ -0,0 +1,165 @@
|
||||||
|
#!/usr/bin/env nix-shell
|
||||||
|
#!nix-shell -i python3 -p 'python3.withPackages (ps: [ ps.requests ])'
|
||||||
|
"""
|
||||||
|
Updates pins in this repo to their latest version.
|
||||||
|
|
||||||
|
This is a custom pinning tool, written because npins doesn't have narHash
|
||||||
|
compatible output for git inputs (it is not SRI), and also doesn't support the
|
||||||
|
Nix immutable tarball protocol which we would like to use when we become public.
|
||||||
|
"""
|
||||||
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
from pathlib import Path
|
||||||
|
import re
|
||||||
|
import dataclasses
|
||||||
|
from typing import Literal
|
||||||
|
import urllib.parse
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
# https://stackoverflow.com/a/51286749
|
||||||
|
class DataclassJSONEncoder(json.JSONEncoder):
|
||||||
|
|
||||||
|
def default(self, o):
|
||||||
|
if dataclasses.is_dataclass(o):
|
||||||
|
return dataclasses.asdict(o)
|
||||||
|
return super().default(o)
|
||||||
|
|
||||||
|
|
||||||
|
@dataclasses.dataclass
|
||||||
|
class PinSerialized:
|
||||||
|
kind: str
|
||||||
|
rev: str | None
|
||||||
|
nar_hash: str
|
||||||
|
|
||||||
|
|
||||||
|
@dataclasses.dataclass
|
||||||
|
class GitPinSerialized(PinSerialized):
|
||||||
|
kind: Literal['git']
|
||||||
|
url: str
|
||||||
|
rev: str
|
||||||
|
ref: str
|
||||||
|
|
||||||
|
|
||||||
|
@dataclasses.dataclass
|
||||||
|
class TarballPinSerialized(PinSerialized):
|
||||||
|
kind: Literal['tarball']
|
||||||
|
locked_url: str
|
||||||
|
url: str
|
||||||
|
|
||||||
|
|
||||||
|
class PinSpec:
|
||||||
|
|
||||||
|
def do_pin(self) -> dict[str, str]:
|
||||||
|
raise ValueError('unimplemented')
|
||||||
|
|
||||||
|
|
||||||
|
@dataclasses.dataclass
|
||||||
|
class GitPinSpec(PinSpec):
|
||||||
|
url: str
|
||||||
|
branch: str
|
||||||
|
|
||||||
|
def do_pin(self) -> GitPinSerialized:
|
||||||
|
return lock_git(self.url, self.branch)
|
||||||
|
|
||||||
|
|
||||||
|
@dataclasses.dataclass
|
||||||
|
class TarballPinSpec(PinSpec):
|
||||||
|
url: str
|
||||||
|
|
||||||
|
def do_pin(self) -> TarballPinSerialized:
|
||||||
|
return lock_tarball(self.url)
|
||||||
|
|
||||||
|
|
||||||
|
@dataclasses.dataclass
|
||||||
|
class LinkHeader:
|
||||||
|
url: str
|
||||||
|
rev: str | None
|
||||||
|
|
||||||
|
|
||||||
|
LINK_HEADER_RE = re.compile(r'<(?P<url>.*)>; rel="immutable"')
|
||||||
|
|
||||||
|
|
||||||
|
def parse_link_header(header) -> LinkHeader | None:
|
||||||
|
matched = LINK_HEADER_RE.match(header)
|
||||||
|
if not matched:
|
||||||
|
return None
|
||||||
|
|
||||||
|
url = matched.group('url')
|
||||||
|
parsed_url = urllib.parse.urlparse(url)
|
||||||
|
parsed_qs = urllib.parse.parse_qs(parsed_url.query)
|
||||||
|
|
||||||
|
return LinkHeader(url=url, rev=next(iter(parsed_qs.get('rev', [])), None))
|
||||||
|
|
||||||
|
|
||||||
|
def lock_tarball(url) -> TarballPinSerialized:
|
||||||
|
"""
|
||||||
|
Prefetches a tarball using the Nix immutable tarball protocol
|
||||||
|
"""
|
||||||
|
import requests
|
||||||
|
resp = requests.get(url)
|
||||||
|
with tempfile.TemporaryDirectory() as td:
|
||||||
|
td = Path(td)
|
||||||
|
proc = subprocess.Popen(["tar", "-C", td, "-xvzf", "-"],
|
||||||
|
stdin=subprocess.PIPE)
|
||||||
|
assert proc.stdin
|
||||||
|
for chunk in resp.iter_content(64 * 1024):
|
||||||
|
proc.stdin.write(chunk)
|
||||||
|
proc.stdin.close()
|
||||||
|
if proc.wait() != 0:
|
||||||
|
raise RuntimeError("untarring failed")
|
||||||
|
|
||||||
|
children = list(td.iterdir())
|
||||||
|
# FIXME: allow different tarball structures
|
||||||
|
assert len(children) == 1
|
||||||
|
|
||||||
|
child = children[0].rename(children[0].parent.joinpath('source'))
|
||||||
|
sri_hash = subprocess.check_output(
|
||||||
|
["nix-hash", "--type", "sha256", "--sri", child]).decode().strip()
|
||||||
|
path = subprocess.check_output(
|
||||||
|
["nix-store", "--add-fixed", "--recursive", "sha256",
|
||||||
|
child]).decode().strip()
|
||||||
|
|
||||||
|
link_info = parse_link_header(resp.headers['Link'])
|
||||||
|
|
||||||
|
print(sri_hash, path)
|
||||||
|
return TarballPinSerialized(kind='tarball',
|
||||||
|
nar_hash=sri_hash,
|
||||||
|
locked_url=link_info.url if link_info else url,
|
||||||
|
rev=link_info.rev if link_info else None,
|
||||||
|
url=url)
|
||||||
|
|
||||||
|
|
||||||
|
def lock_git(url, branch) -> GitPinSerialized:
|
||||||
|
url_escaped = json.dumps(url)
|
||||||
|
ref_escaped = json.dumps(branch)
|
||||||
|
data = json.loads(
|
||||||
|
subprocess.check_output([
|
||||||
|
"nix", "eval", "--impure", "--json", "--expr",
|
||||||
|
f"builtins.removeAttrs (builtins.fetchGit {{ url = {url_escaped}; ref = {ref_escaped}; }}) [ \"outPath\" ]"
|
||||||
|
]).strip())
|
||||||
|
return GitPinSerialized(kind='git',
|
||||||
|
url=url,
|
||||||
|
rev=data['rev'],
|
||||||
|
ref=branch,
|
||||||
|
nar_hash=data['narHash'])
|
||||||
|
|
||||||
|
|
||||||
|
PINS = {
|
||||||
|
'nix-eval-jobs':
|
||||||
|
TarballPinSpec('https://git.lix.systems/lix-project/nix-eval-jobs/archive/main.tar.gz')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
output = {}
|
||||||
|
for (name, pin) in PINS.items():
|
||||||
|
output[name] = pin.do_pin()
|
||||||
|
|
||||||
|
print(output)
|
||||||
|
with open('pins.json', 'w') as fh:
|
||||||
|
json.dump(output, fh, cls=DataclassJSONEncoder)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
3
version.json
Normal file
3
version.json
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"version": "2.92.0-dev"
|
||||||
|
}
|
Loading…
Reference in a new issue