diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml new file mode 100644 index 00000000..6d527718 --- /dev/null +++ b/.github/workflows/nix.yml @@ -0,0 +1,34 @@ +name: Nix Build and Check + +on: + push: + branches: [ main, v4-main ] + pull_request: + branches: [ main, v4-main ] + +jobs: + nix-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Nix + uses: cachix/install-nix-action@v27 + with: + extra_nix_config: | + experimental-features = nix-command flakes + + - name: Check flake + run: nix flake check + + - name: Build package + run: nix build + + - name: Test wikiteam3dumpgenerator + run: | + nix run . -- --help + + - name: Verify reproducibility + run: | + nix build --rebuild + nix path-info --json | jq -r '.[].narHash' diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..c553b632 --- /dev/null +++ b/flake.nix @@ -0,0 +1,56 @@ +{ + description = "wikiteam3 - Nix flake for reproducible wiki archiving"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = { self, nixpkgs }: + let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + + wikiteam3 = pkgs.python3Packages.buildPythonApplication { + pname = "wikiteam3"; + version = "3.11.0"; + + pyproject = true; + + src = ./.; + + build-system = with pkgs.python3Packages; [ + setuptools + ]; + + propagatedBuildInputs = with pkgs.python3Packages; [ + requests + mwclient + mwparserfromhell + file-read-backwards + python-slugify + ]; + + meta = with pkgs.lib; { + description = "Tools for archiving wikis"; + homepage = "https://github.com/saveweb/wikiteam3"; + license = licenses.gpl3; + maintainers = [ "Meta-Introspector Research Group" ]; + }; + }; + + in { + packages.${system} = { + default = wikiteam3; + wikiteam3 = wikiteam3; + }; + + apps.${system}.default = { + type = "app"; + program = "${wikiteam3}/bin/wikiteam3dumpgenerator"; + }; + + devShells.${system}.default = pkgs.mkShell { + buildInputs = [ wikiteam3 ]; + }; + }; +}