Commit 65b32227 authored by Leo's avatar Leo
Browse files

feat(flake): add support flake.nix

parent 53397e84
{
pkgs,
lib,
stdenv,
fetchFromGitLab,
}:
stdenv.mkDerivation rec {
pname = "atools";
version = "20.1.1";
src = fetchFromGitLab {
domain = "gitlab.alpinelinux.org";
owner = "Leo";
repo = pname;
rev = version;
sha256 = "1fa1990wih2fq3afnrwgqvila556lr3a3p9pj339kvana7gzkm7m";
};
doCheck = true;
nativeBuildInputs = with pkgs;
[
lua5_3
redo-sh
bats
scdoc
makeWrapper
] ++ lib.optional pkgs.stdenv.isLinux [ busybox ];
patchPhase = ''
# replace `/bin/ash` in the shebang with the harcoded path
# to the store
for prog in \
aports-lint \
apkbuild-lint \
initd-lint \
apkbuild-fixer \
convert-volatile-source;
do
${if pkgs.stdenv.isLinux then
"substituteInPlace $prog --replace '/usr/bin/env ash' ${pkgs.busybox}/bin/ash"
else
"substituteInPlace $prog --replace '/usr/bin/env ash' ${pkgs.runtimeShell}"
}
done
# Same as the above but with `/usr/bin/lua5.3`
substituteInPlace secfixes-check --replace '/usr/bin/lua5.3' ${pkgs.lua5_3}/bin/lua
'';
buildPhase = ''
redo build
'';
checkPhase = ''
redo check
'';
installPhase = ''
PREFIX=/ DESTDIR="$out" redo install
${if pkgs.stdenv.isLinux then ''
# Wrap all binaries in linux to include binaries provided by
# busybox in its prefix, this is to guarantee the binaries
# have a base level of tooling that matches what is used
# in Alpine Linux
for prog in "$out"/bin/*; do
# do not wrap the lua script
[ "$prog" = "$out"/bin/secfixes-check ] && continue
wrapProgram "$prog" --prefix PATH : ${lib.makeBinPath [ pkgs.busybox ]}
done'' else ''''};
'';
meta = {
homepage = "https://gitlab.alpinelinux.org/Leo/atools";
description = "Auxiliary scripts for abuild";
license = lib.licenses.mit;
platforms = lib.platforms.unix;
};
}
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1644229661,
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1646497237,
"narHash": "sha256-Ccpot1h/rV8MgcngDp5OrdmLTMaUTbStZTR5/sI7zW0=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "062a0c5437b68f950b081bbfc8a699d57a4ee026",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}
{
description = "Collection of linters and fixers for dealing with APKBUILDs and Alpine Linux's aports";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = {
self,
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
packages = {
atools = pkgs.callPackage ./atools.nix {};
};
devShell = pkgs.mkShell {
nativeBuildInputs = with pkgs;
[
redo-sh
bats
scdoc
lua5_3
] ++ lib.optionals pkgs.stdenv.isLinux [ busybox ];
};
});
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment