Files
manjaro-sway-mirror-arm-patch/flake.nix
2023-06-09 18:58:43 +00:00

90 lines
3.4 KiB
Nix

{
description = ''
With `patch-manjaro-sway-mirror-for-arm`, users can easily observe the `/usr/bin/manjaro-sway-mirrors` file for changes and automatically execute a sed command to modify its contents.
This ensures that the desired mirror configuration, specifically changing the output of `$(pacman-mirrors -G)` from "arm-stable" to "stable," is consistently maintained
'';
inputs.nixpkgs.url = "nixpkgs/nixos-23.05";
outputs = { self, nixpkgs }:
let
name = "patch-manjaro-sway-mirror-for-arm";
version = "0.0.1";
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
packages = forAllSystems (system: rec
{
default = nixpkgsFor.${system}.stdenv.mkDerivation {
name = name;
src = self;
buildPhase = "";
installPhase = "mkdir -p $out/bin; install -t $out/bin src/patch-manjaro-sway-mirror-for-arm.sh";
};
pkgbuildFile = nixpkgsFor.${system}.writeTextFile {
name = "PKGBUILD";
text = ''
pkgname=patch-manjaro-sway-mirror-for-arm.sh
pkgver=${version}
pkgrel=1
pkgdesc="Monitors and updates manjaro-sway-mirrors"
arch=('any')
license=('MIT')
depends=()
package() {
install -Dm755 ${default.src}/src/patch-manjaro-sway-mirror-for-arm.sh "''${pkgdir}/usr/bin/patch-manjaro-sway-mirror-for-arm.sh"
}
'';
};
buildScriptdFile = nixpkgsFor.${system}.writeShellScript "build-package.sh" ''
temp_folder=$(mktemp -d)
pushd "$temp_folder"
cp "${pkgbuildFile}" PKGBUILD
${nixpkgsFor.${system}.pacman}/bin/makepkg -s
popd
find "$temp_folder" -name *.zst -exec mv -f {} . \;
rm -rf "$temp_folder"
'';
});
devTaskScripts = forAllSystems (system:
{
autoTag = nixpkgsFor.${system}.writeScript "auto_tag.sh" ''
git tag --force v${version}
git push origin v${version}
'';
});
in
{
packages = packages;
apps = forAllSystems (system:
let
updateLockScript = nixpkgsFor.${system}.writeShellScriptBin "update_flake_lock.sh" ''
nix --experimental-features 'nix-command flakes' flake lock --update-input nixpkgs
nix --experimental-features 'nix-command flakes' build
'';
in
{
default = { type = "app"; program = "${packages.${system}.default}/bin/patch-manjaro-sway-mirror-for-arm.sh"; };
buildPackage = { type = "app"; program = "${packages.${system}.buildScriptdFile}"; };
devTasks = {
updateFlakeLock = { type = "app"; program = "${updateLockScript}/bin/update_flake_lock.sh"; };
autoTag = { type = "app"; program = "${devTaskScripts.${system}.autoTag}"; };
};
});
devShells = forAllSystems (system:
{
default = nixpkgsFor.${system}.mkShell {
name = "dev-shell";
packages = [ nixpkgsFor.${system}.nixpkgs-fmt nixpkgsFor.${system}.shellspec ];
shellHook = ''
. alias.sh
'';
};
});
};
}