mirror of
https://github.com/packwiz/packwiz.git
synced 2025-04-19 13:06:30 +02:00
Nix support & automated update (#130)
* Add a nix flake * Update flake deps and nix package's version nightly * nix-flake: Update vendorSha256 on each push An extra commit will be pushed only if needed * Move flake.* into root directory Update flake.lock * nix-flake: Support more systems, commit hash as version * Don't automatically update flake.lock
This commit is contained in:
parent
d5290ebd32
commit
b8d9727833
28
.github/workflows/nix.yml
vendored
Normal file
28
.github/workflows/nix.yml
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
name: nix
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-vendor-sha:
|
||||||
|
name: vendor-sha
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Checkout repo
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install nix
|
||||||
|
uses: cachix/install-nix-action@v17
|
||||||
|
with:
|
||||||
|
extra_nix_config: |
|
||||||
|
experimental-features = nix-command flakes
|
||||||
|
nix_path: nixpkgs=channel:nixos-unstable
|
||||||
|
|
||||||
|
- name: Update packwiz version
|
||||||
|
run: nix run nixpkgs#nix-prefetch ./nix/prefetcher.nix | tee ./nix/vendor-sha256
|
||||||
|
|
||||||
|
- name: Commit
|
||||||
|
uses: stefanzweifel/git-auto-commit-action@v4
|
||||||
|
with:
|
||||||
|
commit_message: "chore: update packwiz vendorSha256"
|
||||||
|
branch: master
|
||||||
|
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -15,4 +15,7 @@
|
|||||||
# I use GoLand now
|
# I use GoLand now
|
||||||
.idea/
|
.idea/
|
||||||
|
|
||||||
|
# Nix build output
|
||||||
|
result
|
||||||
|
|
||||||
dist/
|
dist/
|
26
flake.lock
generated
Normal file
26
flake.lock
generated
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1655221618,
|
||||||
|
"narHash": "sha256-ht8HRFthDKzYt+il+sGgkBwrv+Ex2l8jdGVpsrPfFME=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "6616de389ed55fba6eeba60377fc04732d5a207c",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"id": "nixpkgs",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"type": "indirect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
44
flake.nix
Normal file
44
flake.nix
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
{
|
||||||
|
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
|
||||||
|
|
||||||
|
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";
|
||||||
|
vendorSha256 = readFile ./nix/vendor-sha256;
|
||||||
|
buildGoModule = pkgs.buildGo118Module;
|
||||||
|
};
|
||||||
|
# Build packwiz by default when no package name is specified
|
||||||
|
default = packwiz;
|
||||||
|
});
|
||||||
|
|
||||||
|
# This flake's nix code formatter
|
||||||
|
formatter = forAllSystems (system: nixpkgsFor.${system}.alejandra);
|
||||||
|
};
|
||||||
|
}
|
38
nix/default.nix
Normal file
38
nix/default.nix
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
let
|
||||||
|
# Import nixpkgs if needed
|
||||||
|
pkgs = import <nixpkgs> {};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
lib ? pkgs.lib,
|
||||||
|
buildGoModule ? pkgs.buildGoModule,
|
||||||
|
fetchFromGitHub ? pkgs.fetchFromGitHub,
|
||||||
|
installShellFiles ? pkgs.installShellFiles,
|
||||||
|
# version and vendorSha256 should be specified by the caller
|
||||||
|
version ? "latest",
|
||||||
|
vendorSha256,
|
||||||
|
}:
|
||||||
|
buildGoModule rec {
|
||||||
|
pname = "packwiz";
|
||||||
|
inherit version vendorSha256;
|
||||||
|
|
||||||
|
src = ./..;
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
installShellFiles
|
||||||
|
];
|
||||||
|
|
||||||
|
# Install shell completions
|
||||||
|
postInstall = ''
|
||||||
|
installShellCompletion --cmd packwiz \
|
||||||
|
--bash <($out/bin/packwiz completion bash) \
|
||||||
|
--fish <($out/bin/packwiz completion fish) \
|
||||||
|
--zsh <($out/bin/packwiz completion zsh)
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = "A command line tool for editing and distributing Minecraft modpacks, using a git-friendly TOML format";
|
||||||
|
homepage = "https://packwiz.infra.link/";
|
||||||
|
license = licenses.mit;
|
||||||
|
mainProgram = "packwiz";
|
||||||
|
};
|
||||||
|
}
|
11
nix/prefetcher.nix
Normal file
11
nix/prefetcher.nix
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
sha256,
|
||||||
|
pkgs ? import <nixpkgs> {},
|
||||||
|
}:
|
||||||
|
pkgs.callPackage (import ./.) {
|
||||||
|
buildGoModule = pkgs.buildGo118Module;
|
||||||
|
vendorSha256 = sha256;
|
||||||
|
}
|
||||||
|
// {
|
||||||
|
outputHash = sha256;
|
||||||
|
}
|
1
nix/vendor-sha256
Normal file
1
nix/vendor-sha256
Normal file
@ -0,0 +1 @@
|
|||||||
|
sha256-M9u7N4IrL0B4pPRQwQG5TlMaGT++w3ZKHZ0RdxEHPKk=
|
Loading…
x
Reference in New Issue
Block a user