nix: boostrap "v2" tree (#3740)

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>
This commit is contained in:
Moritz Sanft 2025-04-04 10:22:28 +02:00 committed by GitHub
parent 0926b82a65
commit e5d22ebcaf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 119 additions and 25 deletions

10
flake.lock generated
View file

@ -18,13 +18,13 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgsUnstable": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1733376361, "lastModified": 1743689281,
"narHash": "sha256-aLJxoTDDSqB+/3orsulE6/qdlX6MzDLIITLZqdgMpqo=", "narHash": "sha256-y7Hg5lwWhEOgflEHRfzSH96BOt26LaYfrYWzZ+VoVdg=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "929116e316068c7318c54eb4d827f7d9756d5e9c", "rev": "2bfc080955153be0be56724be6fa5477b4eefabb",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -37,7 +37,7 @@
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"nixpkgsUnstable": "nixpkgsUnstable" "nixpkgs": "nixpkgs"
} }
}, },
"systems": { "systems": {

View file

@ -2,7 +2,7 @@
description = "Constellation"; description = "Constellation";
inputs = { inputs = {
nixpkgsUnstable = { nixpkgs = {
url = "github:NixOS/nixpkgs/nixpkgs-unstable"; url = "github:NixOS/nixpkgs/nixpkgs-unstable";
}; };
flake-utils = { flake-utils = {
@ -13,21 +13,29 @@
outputs = outputs =
{ {
self, self,
nixpkgsUnstable, nixpkgs,
flake-utils, flake-utils,
}: }:
flake-utils.lib.eachDefaultSystem ( flake-utils.lib.eachDefaultSystem (
system: system:
let let
pkgsUnstable = import nixpkgsUnstable { inherit system; }; pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
callPackage = pkgsUnstable.callPackage; overlays = [
(_final: prev: (import ./nix/packages { inherit (prev) lib callPackage; }))
(_final: prev: { lib = prev.lib // (import ./nix/lib { inherit (prev) lib callPackage; }); })
];
};
callPackage = pkgs.callPackage;
mkosiDev = ( mkosiDev = (
pkgsUnstable.mkosi.overrideAttrs (oldAttrs: { pkgs.mkosi.overrideAttrs (oldAttrs: {
propagatedBuildInputs = propagatedBuildInputs =
oldAttrs.propagatedBuildInputs oldAttrs.propagatedBuildInputs
++ (with pkgsUnstable; [ ++ (with pkgs; [
# package management # package management
dnf5 dnf5
rpm rpm
@ -52,41 +60,48 @@
); );
in in
{ {
# Use `legacyPackages` instead of `packages` for the reason explained here:
# https://github.com/NixOS/nixpkgs/blob/34def00657d7c45c51b0762eb5f5309689a909a5/flake.nix#L138-L156
# Note that it's *not* a legacy attribute.
legacyPackages = {
generate = pkgs.callPackage ./nix/generate.nix { };
} // pkgs;
packages.mkosi = mkosiDev; packages.mkosi = mkosiDev;
packages.uplosi = pkgsUnstable.uplosi; packages.uplosi = pkgs.uplosi;
packages.openssl = callPackage ./nix/cc/openssl.nix { pkgs = pkgsUnstable; }; packages.openssl = callPackage ./nix/cc/openssl.nix { pkgs = pkgs; };
packages.cryptsetup = callPackage ./nix/cc/cryptsetup.nix { packages.cryptsetup = callPackage ./nix/cc/cryptsetup.nix {
pkgs = pkgsUnstable; pkgs = pkgs;
pkgsLinux = import nixpkgsUnstable { system = "x86_64-linux"; }; pkgsLinux = import nixpkgs { system = "x86_64-linux"; };
}; };
packages.libvirt = callPackage ./nix/cc/libvirt.nix { packages.libvirt = callPackage ./nix/cc/libvirt.nix {
pkgs = pkgsUnstable; pkgs = pkgs;
pkgsLinux = import nixpkgsUnstable { system = "x86_64-linux"; }; pkgsLinux = import nixpkgs { system = "x86_64-linux"; };
}; };
packages.libvirtd_base = callPackage ./nix/container/libvirtd_base.nix { packages.libvirtd_base = callPackage ./nix/container/libvirtd_base.nix {
pkgs = pkgsUnstable; pkgs = pkgs;
pkgsLinux = import nixpkgsUnstable { system = "x86_64-linux"; }; pkgsLinux = import nixpkgs { system = "x86_64-linux"; };
}; };
packages.vpn = callPackage ./nix/container/vpn/vpn.nix { packages.vpn = callPackage ./nix/container/vpn/vpn.nix {
pkgs = pkgsUnstable; pkgs = pkgs;
pkgsLinux = import nixpkgsUnstable { system = "x86_64-linux"; }; pkgsLinux = import nixpkgs { system = "x86_64-linux"; };
}; };
packages.awscli2 = pkgsUnstable.awscli2; packages.awscli2 = pkgs.awscli2;
packages.createrepo_c = pkgsUnstable.createrepo_c; packages.createrepo_c = pkgs.createrepo_c;
packages.dnf5 = pkgsUnstable.dnf5; packages.dnf5 = pkgs.dnf5;
devShells.default = callPackage ./nix/shells/default.nix { }; devShells.default = callPackage ./nix/shells/default.nix { };
formatter = nixpkgsUnstable.legacyPackages.${system}.nixpkgs-fmt; formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt;
} }
); );
} }

View file

@ -0,0 +1,3 @@
# Returns a reference to the root path of the Constellation repository.
_: ../../../../.

View file

@ -0,0 +1,12 @@
# Returns a package set originating from the root of the Constellation repository.
# The `files` attribute is a list of paths relative to the root of the repository.
{ lib }:
files:
let
filteredFiles = lib.map (subpath: lib.path.append lib.constellationRepoRoot subpath) files;
in
lib.fileset.toSource {
root = lib.constellationRepoRoot;
fileset = lib.fileset.unions filteredFiles;
}

View file

@ -0,0 +1,3 @@
# Returns the current Continuum version, as defined in `version.txt`.
{ lib }: builtins.readFile (lib.path.append lib.constellationRepoRoot "version.txt")

8
nix/lib/default.nix Normal file
View file

@ -0,0 +1,8 @@
{
lib,
callPackage,
}:
lib.packagesFromDirectoryRecursive {
inherit callPackage;
directory = ./by-name;
}

View file

@ -0,0 +1,26 @@
# A 'wrapped' Go builder for Constellation, which doesn't require a `vendorHash` to be set in each package.
# Instead, one central vendor hash is set here, and all packages inherit it.
{
buildGo124Module,
constellation-canonical-go-package,
}:
args:
(buildGo124Module (
{
# We run tests in CI, so don't run them at build time.
doCheck = false;
# Disable CGO by default.
env.CGO_ENABLED = "0";
}
// args
)).overrideAttrs
(_oldAttrs: {
inherit (constellation-canonical-go-package)
goModules
vendorHash
proxyVendor
deleteVendor
;
})

View file

@ -0,0 +1,19 @@
{
lib,
buildGo124Module,
}:
buildGo124Module {
pname = "constellation-canonical-go-package";
version = lib.constellationVersion;
src = lib.constellationRepoRootSrc [
"go.mod"
"go.sum"
];
vendorHash = "sha256-McWiTTz1HTdG3x0LI87CF6oTRFtxSiV3LCCBJb9YG4U=";
doCheck = false;
proxyVendor = true;
}

8
nix/packages/default.nix Normal file
View file

@ -0,0 +1,8 @@
{
lib,
callPackage,
}:
lib.packagesFromDirectoryRecursive {
inherit callPackage;
directory = ./by-name;
}