mirror of
https://github.com/Mic92/nix-update.git
synced 2024-09-17 13:27:27 +03:00
Merge #165
165: Treefmt, flake-parts... r=Mic92 a=Mic92 Co-authored-by: Jörg Thalheim <joerg@thalheim.io>
This commit is contained in:
commit
cc0f0f9d9a
2
.github/workflows/nix-fmt-checks.yaml
vendored
2
.github/workflows/nix-fmt-checks.yaml
vendored
@ -18,4 +18,4 @@ jobs:
|
||||
uses: cachix/install-nix-action@v20
|
||||
|
||||
- name: Run nix formatter tool
|
||||
run: nix fmt . -- --check
|
||||
run: nix fmt
|
||||
|
67
README.md
67
README.md
@ -5,25 +5,25 @@ designed to work with nixpkgs but also other package sets.
|
||||
|
||||
## Features
|
||||
|
||||
- automatically figure out the latest version of packages from:
|
||||
- codeberg.org
|
||||
- crates.io
|
||||
- gitea.com
|
||||
- github.com
|
||||
- gitlab.com or other instances that uses fetchFromGitLab
|
||||
- notabug.org
|
||||
- pypi
|
||||
- rubygems.org
|
||||
- update buildRustPackage's cargoHash/cargoSha256 and cargoSetupHook's cargoDeps
|
||||
- update buildGoModule's vendorHash/vendorSha256
|
||||
- update buildNpmPackage's npmDepsHash and npmConfigHook's npmDeps
|
||||
- update flake outputs (see `--flake`)
|
||||
- build and run the resulting package (see `--build`,
|
||||
`--run` or `--shell`
|
||||
- commit updated files (see `--commit` flag)
|
||||
- run update scripts (`passthru.updateScript`, see `--use-update-script` flag)
|
||||
- run package tests (see `--test` flag)
|
||||
- specify the system to use (see `--system` flag)
|
||||
- automatically figure out the latest version of packages from:
|
||||
- codeberg.org
|
||||
- crates.io
|
||||
- gitea.com
|
||||
- github.com
|
||||
- gitlab.com or other instances that uses fetchFromGitLab
|
||||
- notabug.org
|
||||
- pypi
|
||||
- rubygems.org
|
||||
- update buildRustPackage's cargoHash/cargoSha256 and cargoSetupHook's cargoDeps
|
||||
- update buildGoModule's vendorHash/vendorSha256
|
||||
- update buildNpmPackage's npmDepsHash and npmConfigHook's npmDeps
|
||||
- update flake outputs (see `--flake`)
|
||||
- build and run the resulting package (see `--build`,
|
||||
`--run` or `--shell`
|
||||
- commit updated files (see `--commit` flag)
|
||||
- run update scripts (`passthru.updateScript`, see `--use-update-script` flag)
|
||||
- run package tests (see `--test` flag)
|
||||
- specify the system to use (see `--system` flag)
|
||||
|
||||
## Installation
|
||||
|
||||
@ -114,7 +114,7 @@ $ nix-update jq --version-regex 'jq-(.*)'
|
||||
By default `nix-update` will locate the file that needs to be patched using the `src` attribute of a derivation.
|
||||
In some cases this heurestic is wrong. One can override the behavior like that:
|
||||
|
||||
``` console
|
||||
```console
|
||||
$ nix-update hello --override-filename pkgs/applications/misc/hello/default.nix
|
||||
```
|
||||
|
||||
@ -126,8 +126,8 @@ from https://updates.signal.org/, but also publishes release information on its
|
||||
GitHub page. In such cases, use the `--url` parameter to direct nix-update to
|
||||
the correct repository:
|
||||
|
||||
``` console
|
||||
nix-update --url https://github.com/signalapp/Signal-Desktop --override-filename pkgs/applications/networking/instant-messengers/signal-desktop/default.nix signal-desktop
|
||||
```console
|
||||
nix-update --url https://github.com/signalapp/Signal-Desktop --override-filename pkgs/applications/networking/instant-messengers/signal-desktop/default.nix signal-desktop
|
||||
```
|
||||
|
||||
With the `--shell`, `--build`, `--test` and `--run` flags the update can be
|
||||
@ -135,7 +135,7 @@ tested. Additionally, the `--review` flag can be used to
|
||||
initiate a run of [nixpkgs-review](https://github.com/Mic92/nixpkgs-review), which will ensure all
|
||||
dependent packages can be built. In order to ensure consistent
|
||||
formatting, the `--format` flag will invoke
|
||||
[nixpkgs-fmt](<https://github.com/nix-community/nixpkgs-fmt>).
|
||||
[nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt).
|
||||
|
||||
```console
|
||||
# Also runs nix-build
|
||||
@ -205,8 +205,7 @@ $ ~/git/nix-update/bin/nix-update --commit hello
|
||||
|
||||
## TODO
|
||||
|
||||
- create pull requests
|
||||
- update unstable packages from git to latest master
|
||||
- create pull requests
|
||||
|
||||
## Known Bugs
|
||||
|
||||
@ -214,18 +213,18 @@ nix-update might not work correctly if a file contain multiple packages
|
||||
as it performs naive search and replace to update version numbers. This
|
||||
might be a problem if:
|
||||
|
||||
- A file contains the same version string for multiple packages.
|
||||
- `name` is used instead of `pname` and/or `${version}` is injected into `name`.
|
||||
- A file contains the same version string for multiple packages.
|
||||
- `name` is used instead of `pname` and/or `${version}` is injected into `name`.
|
||||
|
||||
Related discussions:
|
||||
|
||||
- <https://github.com/repology/repology-updater/issues/854>
|
||||
- <https://github.com/NixOS/nixpkgs/issues/68531#issuecomment-533760929>
|
||||
- <https://github.com/repology/repology-updater/issues/854>
|
||||
- <https://github.com/NixOS/nixpkgs/issues/68531#issuecomment-533760929>
|
||||
|
||||
## Related projects:
|
||||
|
||||
- [nixpkgs-update](https://github.com/ryantm/nixpkgs-update) is
|
||||
optimized for mass-updates in nixpkgs while nix-update is better
|
||||
suited for interactive usage that might require user-intervention
|
||||
i.e. fixing the build and testing the result. nix-update is also not
|
||||
limited to nixpkgs.
|
||||
- [nixpkgs-update](https://github.com/ryantm/nixpkgs-update) is
|
||||
optimized for mass-updates in nixpkgs while nix-update is better
|
||||
suited for interactive usage that might require user-intervention
|
||||
i.e. fixing the build and testing the result. nix-update is also not
|
||||
limited to nixpkgs.
|
||||
|
28
default.nix
28
default.nix
@ -1,39 +1,29 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, src ? ./.
|
||||
}:
|
||||
|
||||
|
||||
with pkgs;
|
||||
python311.pkgs.buildPythonApplication rec {
|
||||
pkgs.python311.pkgs.buildPythonApplication {
|
||||
name = "nix-update";
|
||||
inherit src;
|
||||
buildInputs = [ makeWrapper ];
|
||||
src = ./.;
|
||||
buildInputs = [ pkgs.makeWrapper ];
|
||||
nativeCheckInputs = [
|
||||
python311.pkgs.pytest
|
||||
python311.pkgs.black
|
||||
ruff
|
||||
glibcLocales
|
||||
mypy
|
||||
pkgs.python311.pkgs.pytest
|
||||
pkgs.glibcLocales
|
||||
pkgs.mypy
|
||||
# technically not test inputs, but we need it for development in PATH
|
||||
pkgs.nixVersions.stable or nix_2_4
|
||||
nix-prefetch-git
|
||||
pkgs.nixVersions.stable or pkgs.nix_2_4
|
||||
pkgs.nix-prefetch-git
|
||||
];
|
||||
checkPhase = ''
|
||||
echo -e "\x1b[32m## run black\x1b[0m"
|
||||
LC_ALL=en_US.utf-8 black --check . bin/nix-update
|
||||
echo -e "\x1b[32m## run ruff\x1b[0m"
|
||||
ruff . bin/nix-update
|
||||
echo -e "\x1b[32m## run mypy\x1b[0m"
|
||||
mypy --no-warn-unused-ignores --strict nix_update tests
|
||||
'';
|
||||
makeWrapperArgs = [
|
||||
"--prefix PATH"
|
||||
":"
|
||||
(lib.makeBinPath [ pkgs.nixVersions.stable or nix_2_4 nixpkgs-fmt nixpkgs-review nix-prefetch-git ])
|
||||
(pkgs.lib.makeBinPath [ pkgs.nixVersions.stable or pkgs.nix_2_4 pkgs.nixpkgs-review pkgs.nix-prefetch-git ])
|
||||
];
|
||||
shellHook = ''
|
||||
# workaround because `python setup.py develop` breaks for me
|
||||
'';
|
||||
|
||||
passthru.env = buildEnv { inherit name; paths = buildInputs ++ checkInputs; };
|
||||
}
|
||||
|
54
flake.lock
54
flake.lock
@ -1,40 +1,66 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1678901627,
|
||||
"narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6",
|
||||
"lastModified": 1683560683,
|
||||
"narHash": "sha256-XAygPMN5Xnk/W2c1aW0jyEa6lfMDZWlQgiNtmHXytPc=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "006c75898cf814ef9497252b022e91c946ba8e17",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1679262748,
|
||||
"narHash": "sha256-DQCrrAFrkxijC6haUzOC5ZoFqpcv/tg2WxnyW3np1Cc=",
|
||||
"lastModified": 1684525479,
|
||||
"narHash": "sha256-Cq4jQE5OpB13nuEV3Ahm0UlpzeJBkb3PUz5pox4ih2E=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "60c1d71f2ba4c80178ec84523c2ca0801522e0a6",
|
||||
"rev": "4a22f6f0a4b4354778f786425babce9a56f6b5d8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
"flake-parts": "flake-parts",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"treefmt-nix": "treefmt-nix"
|
||||
}
|
||||
},
|
||||
"treefmt-nix": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1684416994,
|
||||
"narHash": "sha256-KkZ9diPRl3Y05TngWYs/QhZKnI/3tA3s+2Hhmei8FnE=",
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"rev": "42045102f90cfd23ca44ae4ef8362180fefcd7fd",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
25
flake.nix
25
flake.nix
@ -1,19 +1,22 @@
|
||||
{
|
||||
description = "Swiss-knife for updating nix packages.";
|
||||
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem (system: {
|
||||
formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt;
|
||||
treefmt-nix.url = "github:numtide/treefmt-nix";
|
||||
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
packages = {
|
||||
default = self.packages.${system}.nix-update;
|
||||
|
||||
nix-update = nixpkgs.legacyPackages.${system}.callPackage self {
|
||||
src = self;
|
||||
};
|
||||
outputs = inputs @ { flake-parts, ... }:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } ({ lib, ... }: {
|
||||
imports = [ ./treefmt.nix ];
|
||||
systems = lib.systems.flakeExposed;
|
||||
perSystem = { config, pkgs, ... }: {
|
||||
packages.nix-update = pkgs.callPackage ./. { };
|
||||
packages.default = config.packages.nix-update;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
@ -6,4 +6,3 @@
|
||||
},
|
||||
"lockFileMaintenance": { "enabled": true }
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
{ lib
|
||||
, fetchFromGitHub
|
||||
{ fetchFromGitHub
|
||||
, buildNpmPackage
|
||||
}:
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ lib, stdenv, fetchurl, gamin }:
|
||||
{ stdenv, fetchurl, gamin }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "fileschanged";
|
||||
|
45
treefmt.nix
Normal file
45
treefmt.nix
Normal file
@ -0,0 +1,45 @@
|
||||
{ inputs, ... }: {
|
||||
imports = [
|
||||
inputs.treefmt-nix.flakeModule
|
||||
];
|
||||
|
||||
perSystem = { pkgs, ... }: {
|
||||
treefmt = {
|
||||
# Used to find the project root
|
||||
projectRootFile = "flake.lock";
|
||||
|
||||
programs.prettier.enable = true;
|
||||
|
||||
settings.formatter = {
|
||||
nix = {
|
||||
command = "sh";
|
||||
options = [
|
||||
"-eucx"
|
||||
''
|
||||
# First deadnix
|
||||
${pkgs.lib.getExe pkgs.deadnix} --edit "$@"
|
||||
# Then nixpkgs-fmt
|
||||
${pkgs.lib.getExe pkgs.nixpkgs-fmt} "$@"
|
||||
''
|
||||
"--"
|
||||
];
|
||||
includes = [ "*.nix" ];
|
||||
excludes = [ "nix/sources.nix" ];
|
||||
};
|
||||
|
||||
python = {
|
||||
command = "sh";
|
||||
options = [
|
||||
"-eucx"
|
||||
''
|
||||
${pkgs.lib.getExe pkgs.ruff} --fix "$@"
|
||||
${pkgs.lib.getExe pkgs.python3.pkgs.black} "$@"
|
||||
''
|
||||
"--" # this argument is ignored by bash
|
||||
];
|
||||
includes = [ "*.py" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user