packwiz/flake.nix
Nikita c936fe72c5
Update and fix nix flake (#341)
Since nix tries to update inputs on newer versions out of, I suppose,
some introduced incompatibility, `nix build` fails. And nixpkgs from
2023 sounds rather obsolete at this point, so update was kinda due I
think.
On newer versions of nixpkgs however buildGoModule has changed and
requires one of its arguments to be called vendorHash and not
vendorSha256, this patch changes that as well.

Fixes #297, closes #314, closes #307
2025-08-10 21:04:46 +01:00

49 lines
1.7 KiB
Nix

{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# This maps to https://github.com/NixOS/nixpkgs/tree/nixos-unstable
# The `url` option is the pattern of `github:USER_OR_ORG/REPO/BRANCH`
outputs = {
self,
nixpkgs,
}:
with nixpkgs.lib; let
# List of explicetely unsupported systems
explicitelyUnsupportedSystems = [];
# Packwiz should support all 64-bit systems supported by go, but nix only
# support strictly less, so all nix-supported systems are included
# (except ones in explicitelyUnsupportedSystems).
supportedSystems =
filter
# Filter out systems that are explicetely supported
(s: ! elem s explicitelyUnsupportedSystems)
# This lists all systems reasonably well-supported by nix
(import "${nixpkgs}/lib/systems/flake-systems.nix" {});
# Helper generating outputs for each supported system
forAllSystems = genAttrs supportedSystems;
# Import nixpkgs' package set for each system.
nixpkgsFor = forAllSystems (system: import nixpkgs {inherit system;});
in {
# Packwiz package
packages = forAllSystems (system: let
pkgs = nixpkgsFor.${system};
in rec {
packwiz = pkgs.callPackage ./nix {
version = substring 0 8 self.rev or "dirty";
vendorHash = readFile ./nix/vendor-hash;
buildGoModule = pkgs.buildGoModule;
# As of writing, `pkgs.buildGoModule` is aliased to
# `pkgs.buildGo121Module` in Nixpkgs.
};
# Build packwiz by default when no package name is specified
default = packwiz;
});
# This flake's nix code formatter
formatter = forAllSystems (system: nixpkgsFor.${system}.alejandra);
};
}