diff --git a/.github/workflows/nix-build.yml b/.github/workflows/nix-build.yml index 97b1b7592..06ca6fb29 100644 --- a/.github/workflows/nix-build.yml +++ b/.github/workflows/nix-build.yml @@ -2,68 +2,36 @@ name: "Nix Build" on: pull_request: push: - branches: - - development - - master - workflow_dispatch: - + branches: [development, master] jobs: - hooks: - name: Pre-commit hooks - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2.4.0 - - uses: cachix/install-nix-action@v15 - - uses: cachix/cachix-action@v10 - with: - name: smos - extraPullNames: cachix,validity,dirforest,cursor,cursor-dirforest,mergeful,autodocodec - signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' - - run: nix-build ci.nix -A pre-commit-hooks - - shell: - name: Nix shell - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2.4.0 - - uses: cachix/install-nix-action@v15 - - uses: cachix/cachix-action@v10 - with: - name: smos - - run: nix-build ci.nix -A shell - - hoogle: - name: Hoogle - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2.4.0 - - uses: cachix/install-nix-action@v15 - - uses: cachix/cachix-action@v10 - with: - name: smos - - run: nix-build ci.nix -A hoogle - - release: - name: Normal build ${{ matrix.os }} + build: + name: ${{ matrix.attribute }} / ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: - ubuntu-latest - - macos-latest + attribute: + - .#devShells.x86_64-linux.default + - .#packages.x86_64-linux.default + - .#checks.x86_64-linux.pre-commit steps: - - uses: actions/checkout@v2.4.0 - - uses: cachix/install-nix-action@v15 + - uses: actions/checkout@v2.5.0 + - uses: cachix/install-nix-action@v18 + with: + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + system-features = nixos-test benchmark big-parallel kvm - name: free disk space run: | if [[ "${{matrix.os}}" == "ubuntu-latest" ]] then sudo rm -rf /opt fi - - uses: cachix/cachix-action@v10 + - uses: cachix/cachix-action@v12 with: name: smos - extraPullNames: cachix,validity,dirforest,cursor,cursor-dirforest,mergeful,autodocodec + extraPullNames: validity,safe-coloured-text,sydtest,autodocodec,mergeless,mergeful,dirforest,looper,autorecorder,cursor,cursor-dirforest,feedback signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' - - run: nix-build ci.nix -A release + - run: nix build ${{matrix.attribute}} diff --git a/.github/workflows/stack-build.yml b/.github/workflows/stack-build.yml deleted file mode 100644 index cbc2c1891..000000000 --- a/.github/workflows/stack-build.yml +++ /dev/null @@ -1,165 +0,0 @@ -name: "Stack Build" -on: - pull_request: - push: - branches: - - development - - master - workflow_dispatch: - -jobs: - stack-build: - name: ${{ matrix.os }} / Stack ${{ matrix.stack }} / GHC ${{ matrix.ghc }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: - - ubuntu-latest - stack: - - 2.1.3 - ghc: - - 8.6.5 - steps: - - uses: actions/checkout@v2 - if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master' || github.event.ref == 'refs/heads/development' - with: - submodules: recursive - - - name: Get the stripe spec - run: curl https://raw.githubusercontent.com/stripe/openapi/0f89038afd23327b714c5b02812508f7a3cd0a57/openapi/spec3.yaml > spec3.yaml - - - uses: actions/setup-haskell@v1.1.3 - name: Setup Haskell Stack - with: - ghc-version: ${{ matrix.ghc }} - stack-version: ${{ matrix.stack }} - - - name: Cache for stack - uses: actions/cache@v2 - with: - path: | - ~/.stack - .stack-work - key: ${{ runner.os }}-${{ matrix.ghc }}-stack - - - name: Build hpack - run: stack install hpack --stack-yaml setup-stack.yaml - - - name: Build openapi3-code-generator - run: stack install openapi3-code-generator --stack-yaml setup-stack.yaml - - - name: Generate Stripe client - run: ~/.local/bin/openapi3-code-generator-exe --configuration stripe-client-gen.yaml --specification spec3.yaml - - - name: Build autoexporter - run: | - stack install --system-ghc autoexporter - - - name: Build dependencies - run: | - stack build --system-ghc --only-dependencies - - - name: Build smos-data - run: | - stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --pedantic \ - smos-data - - - name: Build smos-data-gen - run: | - stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --pedantic \ - smos-data-gen - - - name: Build smos-report - run: | - stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --pedantic \ - smos-report - - - name: Build smos-report-gen - run: | - stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --pedantic \ - smos-report-gen - - - name: Build smos-calendar-import - run: | - stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --pedantic \ - smos-calendar-import - - - name: Build smos-single - run: | - stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --pedantic \ - smos-single - - - name: Build smos-scheduler - run: | - stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --pedantic \ - smos-scheduler - - - name: Build smos-query - run: | - stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --pedantic \ - smos-query - - - name: Build smos-archive - run: | - stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --pedantic \ - smos-archive - - - name: Build smos-api - run: | - stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --pedantic \ - smos-api - - - name: Build smos-api-gen - run: | - stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --pedantic \ - smos-api-gen - - - name: Build smos-cursor - run: | - stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --pedantic \ - smos-cursor - - - name: Build smos-cursor-gen - run: | - stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --pedantic \ - smos-cursor-gen - - - name: Build smos-report-cursor - run: | - stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --pedantic \ - smos-report-cursor - - - name: Build smos-report-cursor-gen - run: | - stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --pedantic \ - smos-report-cursor-gen - - - name: Build smos-client - run: | - stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --pedantic \ - smos-client - - - name: Build smos-server - run: | - stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --pedantic \ - smos-server - - - name: Build smos-server-gen - run: | - stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --pedantic \ - smos-server-gen - - - name: Build smos-sync-client - run: | - stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --pedantic \ - smos-sync-client - - - name: Build smos-sync-client-gen - run: | - stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --pedantic \ - smos-sync-client-gen - - - name: Build smos - run: | - stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --pedantic \ - smos diff --git a/cabal.project b/cabal.project new file mode 100644 index 000000000..f67383148 --- /dev/null +++ b/cabal.project @@ -0,0 +1,2 @@ +packages: */*.cabal +test-show-details: direct diff --git a/ci.nix b/ci.nix deleted file mode 100644 index dfa10567c..000000000 --- a/ci.nix +++ /dev/null @@ -1,37 +0,0 @@ -let - sources = import ./nix/sources.nix; - pkgs = import ./nix/pkgs.nix { inherit sources; }; - pre-commit = import ./nix/pre-commit.nix { inherit sources; }; -in -{ - "release" = pkgs.smosRelease; - "pre-commit-hooks" = pre-commit.run; - "hoogle" = pkgs.smosHoogle; - "shell" = pkgs.symlinkJoin { - name = "shell"; - paths = (import ./shell.nix { inherit sources pkgs pre-commit; }).buildInputs; - }; - "e2e-test-current-compatibility" = import ./nix/e2e-test.nix { - name = "current-compatibility"; - pathUnderTest = ./.; - sourcesUnderTest = sources; - pkgsUnderTest = pkgs; - pathOverTest = ./.; - sourcesOverTest = sources; - pkgsOverTest = pkgs; - }; - "e2e-test-backward-compatibility" = import ./nix/e2e-test.nix { - name = "backward-compatibility"; - pathUnderTest = ./.; - sourcesUnderTest = sources; - pkgsUnderTest = pkgs; - pathOverTest = sources.smos-latest-release; - }; - "e2e-test-forward-compatibility" = import ./nix/e2e-test.nix { - name = "forward-compatibility"; - pathUnderTest = sources.smos-latest-release; - pathOverTest = ./.; - sourcesOverTest = sources; - pkgsOverTest = pkgs; - }; -} diff --git a/default.nix b/default.nix deleted file mode 100644 index 11e8ee144..000000000 --- a/default.nix +++ /dev/null @@ -1,4 +0,0 @@ -let - pkgs = import ./nix/pkgs.nix { }; -in -pkgs.smosRelease diff --git a/feedback.yaml b/feedback.yaml index db5d5c394..b1dd80349 100644 --- a/feedback.yaml +++ b/feedback.yaml @@ -1,7 +1,7 @@ loops: ci: description: Keep CI passing locally - command: nix-build ci.nix --no-out-link + command: nix flake check server-e2e: description: Work on the server's end-to-end tests diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..9b88ae88c --- /dev/null +++ b/flake.lock @@ -0,0 +1,674 @@ +{ + "nodes": { + "autodocodec": { + "flake": false, + "locked": { + "lastModified": 1666331698, + "narHash": "sha256-VrONoycKv3lOwN/oKet3Pix96aFNgK+PmLevzBgSsgY=", + "owner": "NorfairKing", + "repo": "autodocodec", + "rev": "fdc5171d0f904613b6a8b986a909c7a8ade4d2f1", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "ref": "flake", + "repo": "autodocodec", + "type": "github" + } + }, + "autodocodec_2": { + "flake": false, + "locked": { + "lastModified": 1666331698, + "narHash": "sha256-VrONoycKv3lOwN/oKet3Pix96aFNgK+PmLevzBgSsgY=", + "owner": "NorfairKing", + "repo": "autodocodec", + "rev": "fdc5171d0f904613b6a8b986a909c7a8ade4d2f1", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "ref": "flake", + "repo": "autodocodec", + "type": "github" + } + }, + "autorecorder": { + "flake": false, + "locked": { + "lastModified": 1667054428, + "narHash": "sha256-r70uDYTEJ/cn59ldR1f6M5x6OrOXQQzq9QtK6tpTEew=", + "owner": "NorfairKing", + "repo": "autorecorder", + "rev": "ad63034ea9ab05f980e48536a7281f337a498acc", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "ref": "flake", + "repo": "autorecorder", + "type": "github" + } + }, + "cursor": { + "flake": false, + "locked": { + "lastModified": 1666975590, + "narHash": "sha256-jq4Lx3vCaoT30CfsxbLnwYyaH3FynylspOPhAhoDbVo=", + "owner": "NorfairKing", + "repo": "cursor", + "rev": "967dba32b9362351600c91afc29a270b0e529fe6", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "ref": "flake", + "repo": "cursor", + "type": "github" + } + }, + "cursor-brick": { + "flake": false, + "locked": { + "lastModified": 1667047484, + "narHash": "sha256-wS4loDxhV6T45qdaDvFl1gDEheiY9The2KJIVlWcD/o=", + "owner": "NorfairKing", + "repo": "cursor-brick", + "rev": "8b7c37e5ec452ada46d86ffef8255c6802b0aeb6", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "ref": "flake", + "repo": "cursor-brick", + "type": "github" + } + }, + "cursor-dirforest": { + "flake": false, + "locked": { + "lastModified": 1667048336, + "narHash": "sha256-tu04jtSdnHoBquSzKg6m9cEXGXimcTDaiaF3ogL4fVs=", + "owner": "NorfairKing", + "repo": "cursor-dirforest", + "rev": "9c38f93c3ca1858a0ec9c59034a53e9df2dbb6c7", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "ref": "flake", + "repo": "cursor-dirforest", + "type": "github" + } + }, + "cursor-fuzzy-time": { + "flake": false, + "locked": { + "lastModified": 1667049333, + "narHash": "sha256-crcnh28c1JHxLURD1bEg/HrPSuJtIQ2buiBFjFUoxN0=", + "owner": "NorfairKing", + "repo": "cursor-fuzzy-time", + "rev": "af5583fb4ccb9de6107ba7e907f733a37befbb6a", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "ref": "flake", + "repo": "cursor-fuzzy-time", + "type": "github" + } + }, + "dirforest": { + "flake": false, + "locked": { + "lastModified": 1666989370, + "narHash": "sha256-z6L3SVI6Jxs9oMXnmrbGPVWFB8ogMFtqvcw1B7ThwhU=", + "owner": "NorfairKing", + "repo": "dirforest", + "rev": "f62aacd7124e6709e42989bad0f78340e3794095", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "ref": "flake", + "repo": "dirforest", + "type": "github" + } + }, + "feedback": { + "flake": false, + "locked": { + "lastModified": 1668441237, + "narHash": "sha256-b7uH2W8mt29ft3iVexzIhvzfKEhiybJb/PF36PP2j98=", + "owner": "NorfairKing", + "repo": "feedback", + "rev": "13436dceb6bed3ee864554494fa428946c89a0c8", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "repo": "feedback", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "locked": { + "lastModified": 1644229661, + "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_4": { + "locked": { + "lastModified": 1667077288, + "narHash": "sha256-bdC8sFNDpT0HK74u9fUkpbf1MEzVYJ+ka7NXCdgBoaA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "6ee9ebb6b1ee695d2cacc4faa053a7b9baa76817", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "fuzzy-time": { + "flake": false, + "locked": { + "lastModified": 1666975590, + "narHash": "sha256-jq4Lx3vCaoT30CfsxbLnwYyaH3FynylspOPhAhoDbVo=", + "owner": "NorfairKing", + "repo": "cursor", + "rev": "967dba32b9362351600c91afc29a270b0e529fe6", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "ref": "flake", + "repo": "cursor", + "type": "github" + } + }, + "get-flake": { + "locked": { + "lastModified": 1644686428, + "narHash": "sha256-zkhYsURWFrvEZLkIoBeqFBzSu+cA2u5mo6M8vq9LN7M=", + "owner": "ursi", + "repo": "get-flake", + "rev": "703f15558daa56dfae19d1858bb3046afe68831a", + "type": "github" + }, + "original": { + "owner": "ursi", + "repo": "get-flake", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1667907331, + "narHash": "sha256-bHkAwkYlBjkupPUFcQjimNS8gxWSWjOTevEuwdnp5m0=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "6639e3a837fc5deb6f99554072789724997bc8e5", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-22.05", + "repo": "home-manager", + "type": "github" + } + }, + "linkcheck": { + "flake": false, + "locked": { + "lastModified": 1666446235, + "narHash": "sha256-ZKZJZ7CtVT8PnrZQeyQZGRNhMlmAbeC+lxxbIh0U0ck=", + "owner": "NorfairKing", + "repo": "linkcheck", + "rev": "bb0c6567379232fd9e6d5ae56214804200a63ce0", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "ref": "flake", + "repo": "linkcheck", + "type": "github" + } + }, + "looper": { + "flake": false, + "locked": { + "lastModified": 1666610946, + "narHash": "sha256-byrQaukKnBAKeyiX+gOO918HbLfhtj4Ak6IhYmV+wTU=", + "owner": "NorfairKing", + "repo": "looper", + "rev": "efa1d48c9993caf88de1aeb26a16de37b4a2c0fd", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "ref": "flake", + "repo": "looper", + "type": "github" + } + }, + "mergeful": { + "flake": false, + "locked": { + "lastModified": 1666635739, + "narHash": "sha256-nadbMT/+iGEEeyL1qnSyTS7ZgzsszN9OqJvRp44Gp80=", + "owner": "NorfairKing", + "repo": "mergeful", + "rev": "63ad193c17e2f5fd403869d1b539684b1a6c5d88", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "ref": "flake", + "repo": "mergeful", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1668475027, + "narHash": "sha256-1xDT1pAm+NpH6cnjoC4v+xWGoGimiWZnth2bX899RKA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "032b5c19b09e8bb9b80eba484b58d1b525dc609d", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1668459637, + "narHash": "sha256-HqnWCKujmtu8v0CjzOT0sr7m2AR7+vpbZJOp1R0rodY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "16f4e04658c2ab10114545af2f39db17d51bd1bd", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-22.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1666249138, + "narHash": "sha256-CzK8NA8xEMKAhvHXB8UMODckcH97sZXm6lziKNWLv0M=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "44fc3cb097324c9f9f93313dd3f103e78d722968", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-22.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1645655918, + "narHash": "sha256-ZfbEFRW7o237+A1P7eTKhXje435FCAoe0blj2n20Was=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "77a7a4197740213879b9a1d2e1788c6c8ade4274", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_5": { + "locked": { + "lastModified": 1667292599, + "narHash": "sha256-7ISOUI1aj6UKMPIL+wwthENL22L3+A9V+jS8Is3QsRo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ef2f213d9659a274985778bff4ca322f3ef3ac68", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "openapi-code-generator": { + "inputs": { + "autodocodec": "autodocodec_2", + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_3", + "pre-commit-hooks": "pre-commit-hooks", + "safe-coloured-text": "safe-coloured-text", + "sydtest": "sydtest", + "validity": "validity" + }, + "locked": { + "lastModified": 1666818406, + "narHash": "sha256-uYjZ5M+NeJV5Q4Ps/TicSJJgpzVIJMsEOopBYO5AhmE=", + "owner": "Haskell-OpenAPI-Code-Generator", + "repo": "Haskell-OpenAPI-Client-Code-Generator", + "rev": "b37f645f7305c4e1d205db47debb498cb698ee8c", + "type": "github" + }, + "original": { + "owner": "Haskell-OpenAPI-Code-Generator", + "ref": "flake", + "repo": "Haskell-OpenAPI-Client-Code-Generator", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs_4" + }, + "locked": { + "lastModified": 1666160137, + "narHash": "sha256-8bQu+6poMzUyS2n3C1v3hkO6ZhRzj8Pf3CDCNckqQE4=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "e6c8efee1c108bb27522b9fd25b1cd0eb3288681", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "pre-commit-hooks_2": { + "inputs": { + "flake-utils": "flake-utils_4", + "nixpkgs": "nixpkgs_5" + }, + "locked": { + "lastModified": 1667992213, + "narHash": "sha256-8Ens8ozllvlaFMCZBxg6S7oUyynYx2v7yleC5M0jJsE=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "ebcbfe09d2bd6d15f68de3a0ebb1e4dcb5cd324b", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "autodocodec": "autodocodec", + "autorecorder": "autorecorder", + "cursor": "cursor", + "cursor-brick": "cursor-brick", + "cursor-dirforest": "cursor-dirforest", + "cursor-fuzzy-time": "cursor-fuzzy-time", + "dirforest": "dirforest", + "feedback": "feedback", + "flake-utils": "flake-utils", + "fuzzy-time": "fuzzy-time", + "get-flake": "get-flake", + "home-manager": "home-manager", + "linkcheck": "linkcheck", + "looper": "looper", + "mergeful": "mergeful", + "nixpkgs": "nixpkgs_2", + "openapi-code-generator": "openapi-code-generator", + "pre-commit-hooks": "pre-commit-hooks_2", + "safe-coloured-text": "safe-coloured-text_2", + "seocheck": "seocheck", + "smos-latest-release": "smos-latest-release", + "sydtest": "sydtest_2", + "template-haskell-reload": "template-haskell-reload", + "validity": "validity_2", + "yesod-autoreload": "yesod-autoreload", + "yesod-static-remote": "yesod-static-remote" + } + }, + "safe-coloured-text": { + "flake": false, + "locked": { + "lastModified": 1666332070, + "narHash": "sha256-Jvx1599QUkgzPhdvSOrxEKKBXF42eYv26EgXwM+RguU=", + "owner": "NorfairKing", + "repo": "safe-coloured-text", + "rev": "df6d65d1afb0140d081b685b411dcfe03ae6f789", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "ref": "flake", + "repo": "safe-coloured-text", + "type": "github" + } + }, + "safe-coloured-text_2": { + "flake": false, + "locked": { + "lastModified": 1666332070, + "narHash": "sha256-Jvx1599QUkgzPhdvSOrxEKKBXF42eYv26EgXwM+RguU=", + "owner": "NorfairKing", + "repo": "safe-coloured-text", + "rev": "df6d65d1afb0140d081b685b411dcfe03ae6f789", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "ref": "flake", + "repo": "safe-coloured-text", + "type": "github" + } + }, + "seocheck": { + "flake": false, + "locked": { + "lastModified": 1666446550, + "narHash": "sha256-wX5T3XDlhVnrl8+WYhewb5KTLHKvZFwXFqkFhz+xAAw=", + "owner": "NorfairKing", + "repo": "seocheck", + "rev": "274c97eb1f2947d4b0392bf3b98d3d2c44138242", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "ref": "flake", + "repo": "seocheck", + "type": "github" + } + }, + "smos-latest-release": { + "flake": false, + "locked": { + "lastModified": 1668274109, + "narHash": "sha256-GJ8G37XzL6VKpeVqOOQwT8KVqC21V2fxTFoQxXoDevE=", + "owner": "NorfairKing", + "repo": "smos", + "rev": "465890a08643d1bcdcb62f0e305839bcffa428ff", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "ref": "flake", + "repo": "smos", + "type": "github" + } + }, + "sydtest": { + "flake": false, + "locked": { + "lastModified": 1666335564, + "narHash": "sha256-RUAQuAaCCF+bFXWKQV9lx3Caj9pHp7l5NGnMfBaK05I=", + "owner": "NorfairKing", + "repo": "sydtest", + "rev": "56eb625a7603652f475d0cfd4af50b700e9a5d1e", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "ref": "flake", + "repo": "sydtest", + "type": "github" + } + }, + "sydtest_2": { + "flake": false, + "locked": { + "lastModified": 1666335564, + "narHash": "sha256-RUAQuAaCCF+bFXWKQV9lx3Caj9pHp7l5NGnMfBaK05I=", + "owner": "NorfairKing", + "repo": "sydtest", + "rev": "56eb625a7603652f475d0cfd4af50b700e9a5d1e", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "ref": "flake", + "repo": "sydtest", + "type": "github" + } + }, + "template-haskell-reload": { + "flake": false, + "locked": { + "lastModified": 1666974999, + "narHash": "sha256-TrA3FkupCmo7qE29OydbO/7NQ/JCEgQerrEHBIpSjXc=", + "owner": "NorfairKing", + "repo": "template-haskell-reload", + "rev": "196dd03ac43d1c1bc65fb99d9b93eab7e4b898fe", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "ref": "flake", + "repo": "template-haskell-reload", + "type": "github" + } + }, + "validity": { + "flake": false, + "locked": { + "lastModified": 1666331942, + "narHash": "sha256-xKqunzWw3w7OaKSatckNxn7gCKtusjaj9szhgBWQwAc=", + "owner": "NorfairKing", + "repo": "validity", + "rev": "dc24b655564beaa6750e390e37e64f8b0b67e18f", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "ref": "flake", + "repo": "validity", + "type": "github" + } + }, + "validity_2": { + "flake": false, + "locked": { + "lastModified": 1666331942, + "narHash": "sha256-xKqunzWw3w7OaKSatckNxn7gCKtusjaj9szhgBWQwAc=", + "owner": "NorfairKing", + "repo": "validity", + "rev": "dc24b655564beaa6750e390e37e64f8b0b67e18f", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "ref": "flake", + "repo": "validity", + "type": "github" + } + }, + "yesod-autoreload": { + "flake": false, + "locked": { + "lastModified": 1666454604, + "narHash": "sha256-bywUaqeUhx9bYLf864Zo9JU6tbi6X7Ma+TxLyRBkDp0=", + "owner": "NorfairKing", + "repo": "yesod-autoreload", + "rev": "7cd3145b1a29bd60e18c1fdcc666b4babe3507df", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "ref": "flake", + "repo": "yesod-autoreload", + "type": "github" + } + }, + "yesod-static-remote": { + "flake": false, + "locked": { + "lastModified": 1666454779, + "narHash": "sha256-TCs5uIM9v0tXDiJCA02H04AxOccOTeKnvciw5ZcZQls=", + "owner": "NorfairKing", + "repo": "yesod-static-remote", + "rev": "a1c82a87e1b2c394fae4bf1f6b732a376444abc6", + "type": "github" + }, + "original": { + "owner": "NorfairKing", + "ref": "flake", + "repo": "yesod-static-remote", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..4acec847e --- /dev/null +++ b/flake.nix @@ -0,0 +1,207 @@ +{ + description = "smos"; + nixConfig = { + extra-substituters = "https://smos.cachix.org"; + extra-trusted-public-keys = "smos.cachix.org-1:YOs/tLEliRoyhx7PnNw36cw2Zvbw5R0ASZaUlpUv+yM="; + }; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-22.05"; + home-manager.url = "github:nix-community/home-manager?ref=release-22.05"; + flake-utils.url = "github:numtide/flake-utils"; + pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix"; + validity.url = "github:NorfairKing/validity?ref=flake"; + validity.flake = false; + autodocodec.url = "github:NorfairKing/autodocodec?ref=flake"; + autodocodec.flake = false; + safe-coloured-text.url = "github:NorfairKing/safe-coloured-text?ref=flake"; + safe-coloured-text.flake = false; + sydtest.url = "github:NorfairKing/sydtest?ref=flake"; + sydtest.flake = false; + mergeful.url = "github:NorfairKing/mergeful?ref=flake"; + mergeful.flake = false; + looper.url = "github:NorfairKing/looper?ref=flake"; + looper.flake = false; + cursor.url = "github:NorfairKing/cursor?ref=flake"; + cursor.flake = false; + cursor-brick.url = "github:NorfairKing/cursor-brick?ref=flake"; + cursor-brick.flake = false; + fuzzy-time.url = "github:NorfairKing/cursor?ref=flake"; + fuzzy-time.flake = false; + cursor-fuzzy-time.url = "github:NorfairKing/cursor-fuzzy-time?ref=flake"; + cursor-fuzzy-time.flake = false; + dirforest.url = "github:NorfairKing/dirforest?ref=flake"; + dirforest.flake = false; + cursor-dirforest.url = "github:NorfairKing/cursor-dirforest?ref=flake"; + cursor-dirforest.flake = false; + yesod-autoreload.url = "github:NorfairKing/yesod-autoreload?ref=flake"; + yesod-autoreload.flake = false; + yesod-static-remote.url = "github:NorfairKing/yesod-static-remote?ref=flake"; + yesod-static-remote.flake = false; + template-haskell-reload.url = "github:NorfairKing/template-haskell-reload?ref=flake"; + template-haskell-reload.flake = false; + openapi-code-generator.url = "github:Haskell-OpenAPI-Code-Generator/Haskell-OpenAPI-Client-Code-Generator?ref=flake"; + autorecorder.url = "github:NorfairKing/autorecorder?ref=flake"; + autorecorder.flake = false; + linkcheck.url = "github:NorfairKing/linkcheck?ref=flake"; + linkcheck.flake = false; + seocheck.url = "github:NorfairKing/seocheck?ref=flake"; + seocheck.flake = false; + feedback.url = "github:NorfairKing/feedback"; + feedback.flake = false; + get-flake.url = "github:ursi/get-flake"; + # TODO[after-release] + # Important: The current flake branch must only be merged on top of a + # release without any other changes. + # Make this ?ref=release so we actually do forward and backward compatibiilty testing. + smos-latest-release.url = "github:NorfairKing/smos?ref=flake"; + smos-latest-release.flake = false; + }; + + outputs = + { self + , nixpkgs + , home-manager + , flake-utils + , pre-commit-hooks + , validity + , safe-coloured-text + , sydtest + , autodocodec + , mergeful + , looper + , cursor + , cursor-brick + , fuzzy-time + , cursor-fuzzy-time + , dirforest + , cursor-dirforest + , yesod-autoreload + , yesod-static-remote + , template-haskell-reload + , openapi-code-generator + , autorecorder + , linkcheck + , seocheck + , feedback + , get-flake + , smos-latest-release + }: + let + system = "x86_64-linux"; + pkgsFor = nixpkgs: import nixpkgs { + inherit system; + overlays = [ + self.overlays.${system} + (import (autodocodec + "/nix/overlay.nix")) + (import (safe-coloured-text + "/nix/overlay.nix")) + (import (sydtest + "/nix/overlay.nix")) + (import (mergeful + "/nix/overlay.nix")) + (import (validity + "/nix/overlay.nix")) + (import (looper + "/nix/overlay.nix")) + (import (cursor + "/nix/overlay.nix")) + (import (cursor-brick + "/nix/overlay.nix")) + (import (fuzzy-time + "/nix/overlay.nix")) + (import (cursor-fuzzy-time + "/nix/overlay.nix")) + (import (dirforest + "/nix/overlay.nix")) + (import (cursor-dirforest + "/nix/overlay.nix")) + (import (yesod-autoreload + "/nix/overlay.nix")) + (import (yesod-static-remote + "/nix/overlay.nix")) + (import (template-haskell-reload + "/nix/overlay.nix")) + (import (openapi-code-generator + "/nix/overlay.nix")) + (import (autorecorder + "/nix/overlay.nix")) + (import (linkcheck + "/nix/overlay.nix")) + (import (seocheck + "/nix/overlay.nix")) + (import (feedback + "/nix/overlay.nix")) + (_:_: { generateOpenAPIClient = openapi-code-generator.packages.${system}.default.passthru.generateOpenAPIClient; }) + (_:_: { evalNixOSConfig = args: import (nixpkgs + "/nixos/lib/eval-config.nix") (args // { inherit system; }); }) + ]; + }; + pkgs = pkgsFor nixpkgs; + mkE2ETestNixOSModule = import ./nix/end-to-end-test-nixos-module.nix { + inherit (pkgs.smosReleasePackages) smos-server-gen; + }; + mkNixOSModule = import ./nix/nixos-module.nix { + inherit (pkgs.smosReleasePackages) smos-docs-site smos-server smos-web-server; + inherit (pkgs.haskellPackages) looper; + }; + in + { + overlays.${system} = import ./nix/overlay.nix; + packages.${system} = { + default = pkgs.smosRelease; + nixosModuleDocs = pkgs.nixosModuleDocs; + homeManagerModuleDocs = pkgs.homeManagerModuleDocs; + generatedSmosStripeCode = pkgs.generatedSmosStripeCode; + }; + apps.${system}.default = { type = "app"; program = "${pkgs.smosReleasePackages.smos}/bin/smos"; }; + checks.${system} = + let + mkE2ETest = import ./nix/e2e-test.nix { + inherit (pkgs) nixosTest; + inherit system get-flake; + home-manager = home-manager.nixosModules.home-manager; + }; + in + { + release = self.packages.${system}.default; + shell = self.devShells.${system}.default; + e2e-test-current-compatibility = mkE2ETest { + name = "current-compatibility"; + flakeUnderTest = self; + flakeOverTest = self; + }; + e2e-test-backward-compatibility = mkE2ETest { + name = "backward-compatibility"; + flakeUnderTest = self; + flakeOverTest = get-flake smos-latest-release; + }; + e2e-test-forward-compatibility = mkE2ETest { + name = "forward-compatibility"; + flakeUnderTest = self; + flakeOverTest = get-flake smos-latest-release; + }; + pre-commit = pre-commit-hooks.lib.${system}.run { + src = ./.; + hooks = { + hlint.enable = true; + hpack.enable = true; + ormolu.enable = true; + nixpkgs-fmt.enable = true; + nixpkgs-fmt.excludes = [ ".*/default.nix" ]; + cabal2nix.enable = true; + }; + }; + }; + devShells.${system}.default = pkgs.haskellPackages.shellFor { + name = "smos-shell"; + packages = p: builtins.attrValues p.smosPackages; + withHoogle = true; + doBenchmark = true; + buildInputs = (with pkgs; [ + niv + zlib + cabal-install + sass + pkgs.feedback + pkgs.autorecorder + ]) ++ (with pre-commit-hooks.packages.${system}; + [ + hlint + hpack + nixpkgs-fmt + ormolu + cabal2nix + ]); + shellHook = self.checks.${system}.pre-commit.shellHook + pkgs.feedback.shellHook; + }; + nixosModules.${system} = { + default = mkNixOSModule { envname = "production"; }; + e2eTest = mkE2ETestNixOSModule { envname = "production"; }; + }; + nixosModuleFactories.${system} = { + default = mkNixOSModule; + e2eTest = mkE2ETestNixOSModule; + }; + homeManagerModules.${system}.default = import ./nix/home-manager-module.nix { smosReleasePackages = pkgs.smosReleasePackages; }; + }; +} diff --git a/milestones.smos b/milestones.smos deleted file mode 100644 index c1d05209a..000000000 --- a/milestones.smos +++ /dev/null @@ -1,109 +0,0 @@ -- entry: - header: Milestones - contents: Inspired by https://hledger.org/ROADMAP.html#milestones - state-history: - - state: TODO - time: 2019-12-19 10:39:06.663413557000 - forest: - - header: 1.0 release - state-history: - - state: TODO - time: 2019-12-19 10:39:06.663413557000 - - entry: - header: Packaged in distros - state-history: - - state: TODO - time: 2019-12-19 10:39:06.663413557000 - forest: - - header: Arch linux - state-history: - - state: TODO - time: 2019-12-19 10:39:06.663413557000 - - header: Debian - state-history: - - state: TODO - time: 2019-12-19 10:39:06.663413557000 - - header: Ubuntu - state-history: - - state: TODO - time: 2019-12-19 10:39:06.663413557000 - - header: NixOs - state-history: - - state: DONE - time: 2020-10-12 10:32:47.142411757000 - - state: TODO - time: 2019-12-19 10:39:29.543295169000 - - entry: - header: Committers - state-history: - - state: TODO - time: 2019-12-19 10:39:06.663413557000 - forest: - - header: '10' - state-history: - - state: DONE - time: 2020-10-06 08:45:23.568442051000 - - state: TODO - time: 2019-12-19 10:39:06.663413557000 - - header: '100' - state-history: - - state: TODO - time: 2019-12-19 10:39:06.663413557000 - - header: '1000' - state-history: - - state: TODO - time: 2019-12-19 10:39:06.663413557000 - - entry: - header: Github stars - state-history: - - state: TODO - time: 2019-12-19 10:39:06.663413557000 - forest: - - header: '10' - state-history: - - state: DONE - time: 2019-12-19 10:39:16.839724225000 - - state: TODO - time: 2019-12-19 10:39:06.663413557000 - - header: '100' - state-history: - - state: DONE - time: 2020-01-09 19:50:03.024359949000 - - state: TODO - time: 2019-12-19 10:39:06.663413557000 - - header: '1000' - state-history: - - state: TODO - time: 2019-12-19 10:39:06.663413557000 - - header: '10000' - state-history: - - state: TODO - time: 2019-12-19 10:39:06.663413557000 - - header: Github document viewing support - state-history: - - state: TODO - time: 2019-12-19 10:39:06.663413557000 - - header: Multiple people providing support - state-history: - - state: TODO - time: 2019-12-19 10:39:06.663413557000 - - header: Discussed on hackernews - state-history: - - state: TODO - time: 2019-12-19 10:39:06.663413557000 - - header: Among top github's trending haskell projects - state-history: - - state: TODO - time: 2019-12-19 10:39:06.663413557000 - - header: Nice Tutorial docs - state-history: - - state: TODO - time: 2019-12-19 10:39:06.663413557000 - - header: Multiple people writing blogposts about it - state-history: - - state: TODO - time: 2019-12-19 10:39:06.663413557000 - - header: Best in class for GTD in a TUI - state-history: - - state: TODO - time: 2019-12-19 10:39:06.663413557000 diff --git a/nix/e2e-test.nix b/nix/e2e-test.nix index 2bee09246..b04925c16 100644 --- a/nix/e2e-test.nix +++ b/nix/e2e-test.nix @@ -1,39 +1,23 @@ -let - sourcesFor = path: - import (path + "/nix/sources.nix"); - pkgsFor = path: sources: - import (path + "/nix/pkgs.nix") { inherit sources; }; - -in -{ name ? "smos-e2e-test" -, pathUnderTest ? ../. -, sourcesUnderTest ? sourcesFor pathUnderTest -, pkgsUnderTest ? pkgsFor pathUnderTest sourcesUnderTest -, smosReleasePackagesUnderTest ? pkgsUnderTest.smosReleasePackages -, pathOverTest ? ../. -, sourcesOverTest ? sourcesFor pathOverTest -, pkgsOverTest ? pkgsFor pathOverTest sourcesOverTest -, smosReleasePackagesOverTest ? pkgsOverTest.smosReleasePackages +{ nixosTest +, system +, get-flake +, home-manager +}: +{ name +, flakeUnderTest +, flakeOverTest }: - # This module is not symmetric. # # The packages under test are on the client side. # The packages over test are on the server side. # # If you want to test both directions, call this tests twice with reversed arguments. -# -# See this for more info about nixos tests -# https://github.com/NixOS/nixpkgs/blob/99d379c45c793c078af4bb5d6c85459f72b1f30b/nixos/lib/testing-python.nix +nixosTest ({ lib, pkgs, ... }: +with lib; let - # Server-side configuration - serverModule = import (pathOverTest + "/nix/nixos-module.nix") { - sources = sourcesOverTest; - pkgs = pkgsOverTest; - smosReleasePackages = smosReleasePackagesOverTest; - envname = "testing"; - }; + serverModule = flakeOverTest.nixosModules.${system}.default; docs-port = 8001; api-port = 8002; @@ -41,21 +25,14 @@ let # E2E testing configuration - e2eTestingModule = import (pathOverTest + "/nix/end-to-end-test-nixos-module.nix") { - sources = sourcesOverTest; - smosReleasePackages = smosReleasePackagesOverTest; - envname = "testing"; - }; + e2eTestingModule = flakeOverTest.nixosModules.${system}.e2eTest; # Client side configuration - home-manager = import (pkgsUnderTest.home-manager.src + "/nixos/default.nix"); - clientModule = import (pathUnderTest + "/nix/home-manager-module.nix"); + clientModule = flakeUnderTest.homeManagerModules.${system}.default; commonConfig = { - imports = [ - clientModule - ]; - # We must enable xdg so that : + imports = [ clientModule ]; + # We must enable xdg so that: # * We can test that .config files are put there # * The ~/.config directory exist # Because the systemd user services are stored in .config/systemd/user @@ -63,89 +40,79 @@ let xdg.enable = true; programs.smos = { enable = true; - smosReleasePackages = smosReleasePackagesUnderTest; }; }; - testUsers = builtins.mapAttrs (name: config: pkgsUnderTest.lib.recursiveUpdate commonConfig config) - { - "nothing_enabled" = { - programs.smos = { }; - }; - "backup_enabled" = { - programs.smos = { - backup.enable = true; - }; - }; - "sync_enabled" = { - programs.smos = { - sync = { - enable = true; - server-url = "apiserver:${builtins.toString api-port}"; - username = "sync_enabled"; - password = "testpassword"; - }; - }; - }; - "scheduler_enabled" = { - programs.smos = { - scheduler.enable = true; + testUsers = builtins.mapAttrs (name: config: recursiveUpdate commonConfig config) { + "nothing_enabled" = { }; + "backup_enabled" = { + programs.smos.backup.enable = true; + }; + "sync_enabled" = { + programs.smos = { + sync = { + enable = true; + server-url = "apiserver:${builtins.toString api-port}"; + username = "sync_enabled"; + password = "testpassword"; }; }; - "calendar_enabled" = { - programs.smos = { - calendar = { - enable = true; - sources = [ - { - name = "Example"; - destination = "calendar.smos"; - source = "${../smos-calendar-import/test_resources/example.ics}"; - } - ]; - }; + }; + "scheduler_enabled" = { + programs.smos.scheduler.enable = true; + }; + "calendar_enabled" = { + programs.smos = { + calendar = { + enable = true; + sources = [ + { + name = "Example"; + destination = "calendar.smos"; + source = "${../smos-calendar-import/test_resources/example.ics}"; + } + ]; }; }; - "notify_enabled" = { - programs.smos = { - notify.enable = true; + }; + "notify_enabled" = { + programs.smos.notify.enable = true; + }; + "github_enabled" = { + programs.smos.github.enable = true; + }; + "everything_enabled" = { + programs.smos = { + backup.enable = true; + sync = { + enable = true; + server-url = "apiserver:${builtins.toString api-port}"; + username = "everything_enabled"; + password = "testpassword"; }; - }; - "everything_enabled" = { - programs.smos = { - backup.enable = true; - sync = { - enable = true; - server-url = "apiserver:${builtins.toString api-port}"; - username = "everything_enabled"; - password = "testpassword"; - }; - scheduler = { - enable = true; - }; - calendar = { - enable = true; - sources = [ - { - name = "Example"; - destination = "calendar.smos"; - source = "${../smos-calendar-import/test_resources/example.ics}"; - } - ]; - }; - notify = { - enable = true; - }; + scheduler.enable = true; + calendar = { + enable = true; + sources = [ + { + name = "Example"; + destination = "calendar.smos"; + source = "${../smos-calendar-import/test_resources/example.ics}"; + } + ]; }; + notify.enable = true; + github.enable = true; }; }; + }; makeTestUser = _: _: { isNormalUser = true; }; makeTestUserHome = username: userConfig: { lib, ... }: userConfig; # The strange formatting is because of the stupid linting that nixos tests do - commonTestScript = username: userConfig: pkgsUnderTest.lib.optionalString (userConfig.programs.smos.enable or false) '' + commonTestScript = username: userConfig: optionalString (userConfig.programs.smos.enable or false) '' # Wait for the test user to be activated. client.wait_for_unit("home-manager-${username}.service") @@ -157,17 +124,13 @@ let # Make sure the user can run the smos commands. client.succeed(su("${username}", "smos --help")) client.succeed(su("${username}", "smos-archive --help")) - client.succeed(su("${username}", "smos-calendar-import --help")) - client.succeed(su("${username}", "smos-github --help")) client.succeed(su("${username}", "smos-query --help")) - client.succeed(su("${username}", "smos-scheduler --help")) client.succeed(su("${username}", "smos-single --help")) - client.succeed(su("${username}", "smos-sync-client --help")) # Make sure the config file is parseable client.succeed(su("${username}", "smos-query next"))''; - backupTestScript = username: userConfig: pkgsUnderTest.lib.optionalString (userConfig.programs.smos.backup.enable or false) '' + backupTestScript = username: userConfig: optionalString (userConfig.programs.smos.backup.enable or false) '' # Test that the local backup service and timer exist. client.get_unit_info("smos-backup.service", user="${username}") @@ -177,7 +140,10 @@ let (c, _) = client.systemctl("start --wait smos-backup.service", user="${username}") assert c == 0;''; - syncTestScript = username: userConfig: pkgsUnderTest.lib.optionalString (userConfig.programs.smos.sync.enable or false) '' + syncTestScript = username: userConfig: optionalString (userConfig.programs.smos.sync.enable or false) '' + + # Test that the sync client is installed + client.succeed(su("${username}", "smos-sync-client --help")) # Test that syncing works. client.succeed(su("${username}", "smos-sync-client register")) @@ -194,7 +160,10 @@ let (c, _) = client.systemctl("start --wait smos-sync.service", user="${username}") assert c == 0;''; - schedulerTestScript = username: userConfig: pkgsUnderTest.lib.optionalString (userConfig.programs.smos.scheduler.enable or false) '' + schedulerTestScript = username: userConfig: optionalString (userConfig.programs.smos.scheduler.enable or false) '' + + # Test that the scheduler is installed + client.succeed(su("${username}", "smos-scheduler --help")) # Test that the scheduler can activate. client.succeed(su("${username}", "smos-scheduler check")) @@ -209,10 +178,10 @@ let assert c == 0;''; # Tests for smos-calendar-import and its systemd service and timer - calendarTestScript = username: userConfig: pkgsUnderTest.lib.optionalString (userConfig.programs.smos.calendar.enable or false) '' + calendarTestScript = username: userConfig: optionalString (userConfig.programs.smos.calendar.enable or false) '' # Test that the calendar can activate. - client.succeed(su("${username}", "smos-calendar-import")) + client.succeed(su("${username}", "smos-calendar-import --help")) # Test that the scheduler service and timer exist. client.get_unit_info("smos-calendar-import.service", user="${username}") @@ -223,9 +192,12 @@ let assert c == 0;''; # Tests for smos-notify and its systemd service and timer - notifyTestScript = username: userConfig: pkgsUnderTest.lib.optionalString (userConfig.programs.smos.notify.enable or false) '' + notifyTestScript = username: userConfig: optionalString (userConfig.programs.smos.notify.enable or false) '' + + # Test that notify is installed + client.succeed(su("${username}", "smos-notify --help")) - # Test that the notify can activate. + # Test that notify can activate. client.succeed(su("${username}", "smos-notify")) # Test that the notify service and timer exist. @@ -236,151 +208,156 @@ let (c, _) = client.systemctl("start --wait smos-notify.service", user="${username}") assert c == 0;''; - userTestScript = username: userConfig: pkgsUnderTest.lib.concatStrings [ + # Tests for smos-github + githubTestScript = username: userConfig: optionalString (userConfig.programs.smos.github.enable or false) '' + + # Test that smos-github is installed. + client.succeed(su("${username}", "smos-github --help"))''; + + userTestScript = username: userConfig: concatStrings [ (commonTestScript username userConfig) (backupTestScript username userConfig) (syncTestScript username userConfig) (schedulerTestScript username userConfig) (calendarTestScript username userConfig) (notifyTestScript username userConfig) + (githubTestScript username userConfig) ]; in -pkgsUnderTest.nixosTest ( - { lib, ... }: { - inherit name; - nodes = { - apiserver = { - imports = [ - serverModule - ]; - services.smos.testing = { +{ + inherit name; + nodes = { + apiserver = { + imports = [ + serverModule + ]; + services.smos.production = { + enable = true; + api-server = { enable = true; - api-server = { + port = api-port; + admin = "admin"; + auto-backup = { enable = true; - port = api-port; - admin = "admin"; - auto-backup = { - enable = true; - phase = 1; - period = 5; - }; - backup-garbage-collector = { - enable = false; - }; + phase = 1; + period = 5; + }; + backup-garbage-collector = { + enable = false; }; }; }; - webserver = { - imports = [ - serverModule - ]; - services.smos.testing = { + }; + webserver = { + imports = [ + serverModule + ]; + services.smos.production = { + enable = true; + web-server = { enable = true; - web-server = { - enable = true; - port = web-port; - docs-url = "docsserver:${builtins.toString docs-port}"; - api-url = "apiserver:${builtins.toString api-port}"; - web-url = "webserver:${builtins.toString web-port}"; - }; + port = web-port; + docs-url = "docsserver:${builtins.toString docs-port}"; + api-url = "apiserver:${builtins.toString api-port}"; + web-url = "webserver:${builtins.toString web-port}"; }; }; - docsserver = { - imports = [ - serverModule - ]; - services.smos.testing = { + }; + docsserver = { + imports = [ + serverModule + ]; + services.smos.production = { + enable = true; + docs-site = { enable = true; - docs-site = { - enable = true; - port = docs-port; - api-url = "apiserver:${builtins.toString api-port}"; - web-url = "webserver:${builtins.toString web-port}"; - }; + port = docs-port; + api-url = "apiserver:${builtins.toString api-port}"; + web-url = "webserver:${builtins.toString web-port}"; }; }; - client = { config, ... }: { - imports = [ - home-manager - ]; - users.users = lib.mapAttrs makeTestUser testUsers; - system.activationScripts = { - # We must enable lingering so that the Systemd User D-Bus is enabled. - # We also cannot do this with loginctl enable-linger because it needs to happen before systemd is loaded. - # It would be nice if there were a nixos option for this. - # See https://github.com/NixOS/nixpkgs/issues/3702 - enableLingering = - let touchUserLinger = username: _: "touch /var/lib/systemd/linger/${username}"; - in - '' - # remove all existing lingering users - rm -rf /var/lib/systemd/linger - mkdir -p /var/lib/systemd/linger - # enable for the subset of declared users - ${lib.concatStringsSep "\n" (lib.mapAttrsToList touchUserLinger config.users.users)} - ''; - }; + }; + client = { config, ... }: { + imports = [ + home-manager + ]; + users.users = mapAttrs makeTestUser testUsers; + system.activationScripts = { + # We must enable lingering so that the Systemd User D-Bus is enabled. + # We also cannot do this with loginctl enable-linger because it needs to happen before systemd is loaded. + # It would be nice if there were a nixos option for this. + # See https://github.com/NixOS/nixpkgs/issues/3702 + enableLingering = + let touchUserLinger = username: _: "touch /var/lib/systemd/linger/${username}"; + in + '' + # remove all existing lingering users + rm -rf /var/lib/systemd/linger + mkdir -p /var/lib/systemd/linger + # enable for the subset of declared users + ${concatStringsSep "\n" (mapAttrsToList touchUserLinger config.users.users)} + ''; + }; - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - users = lib.mapAttrs makeTestUserHome testUsers; - }; + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + users = mapAttrs makeTestUserHome testUsers; }; - e2etestclient = { - imports = [ - e2eTestingModule - ]; - services.smos.testing.end-to-end-testing = { + }; + e2etestclient = { + imports = [ + e2eTestingModule + ]; + services.smos.production.end-to-end-testing = { + enable = true; + api-server = { enable = true; - api-server = { - enable = true; - tests = { - testing = { - enable = true; - api-url = "apiserver:${builtins.toString api-port}"; - time = "00:00"; - }; + tests = { + testing = { + enable = true; + api-url = "apiserver:${builtins.toString api-port}"; + time = "00:00"; }; }; }; }; }; - testScript = '' - from shlex import quote - - apiserver.start() - webserver.start() - docsserver.start() - client.start() - e2etestclient.start() - apiserver.wait_for_unit("multi-user.target") - webserver.wait_for_unit("multi-user.target") - docsserver.wait_for_unit("multi-user.target") - client.wait_for_unit("multi-user.target") - e2etestclient.wait_for_unit("multi-user.target") - - print("starting end-to-end-tests") - client.systemctl("start smos-api-server-end-to-end-test-testing-testing.timer") - client.systemctl("start smos-api-server-end-to-end-test-testing-testing.service --wait") - print("end-to-end-tests done") - - - apiserver.wait_for_open_port(${builtins.toString api-port}) - client.succeed("curl apiserver:${builtins.toString api-port}") - webserver.wait_for_open_port(${builtins.toString web-port}) - client.succeed("curl webserver:${builtins.toString web-port}") - docsserver.wait_for_open_port(${builtins.toString docs-port}) - client.succeed("curl docsserver:${builtins.toString docs-port}") + }; + testScript = '' + from shlex import quote + + apiserver.start() + webserver.start() + docsserver.start() + client.start() + e2etestclient.start() + apiserver.wait_for_unit("multi-user.target") + webserver.wait_for_unit("multi-user.target") + docsserver.wait_for_unit("multi-user.target") + client.wait_for_unit("multi-user.target") + e2etestclient.wait_for_unit("multi-user.target") + + print("starting end-to-end-tests") + client.systemctl("start smos-api-server-end-to-end-test-testing-testing.timer") + client.systemctl("start smos-api-server-end-to-end-test-testing-testing.service --wait") + print("end-to-end-tests done") + + + apiserver.wait_for_open_port(${builtins.toString api-port}) + client.succeed("curl apiserver:${builtins.toString api-port}") + webserver.wait_for_open_port(${builtins.toString web-port}) + client.succeed("curl webserver:${builtins.toString web-port}") + docsserver.wait_for_open_port(${builtins.toString docs-port}) + client.succeed("curl docsserver:${builtins.toString docs-port}") - def su(user, cmd): - return f"su - {user} -c {quote(cmd)}" + def su(user, cmd): + return f"su - {user} -c {quote(cmd)}" - # Run the test script for each user - ${lib.concatStrings (lib.mapAttrsToList userTestScript testUsers)} - ''; - } -) + # Run the test script for each user + ${concatStrings (mapAttrsToList userTestScript testUsers)} + ''; +}) diff --git a/nix/end-to-end-test-nixos-module.nix b/nix/end-to-end-test-nixos-module.nix index e79245f02..0ffff3282 100644 --- a/nix/end-to-end-test-nixos-module.nix +++ b/nix/end-to-end-test-nixos-module.nix @@ -1,6 +1,6 @@ +{ smos-server-gen +}: { envname -, sources ? import ./sources.nix -, smosReleasePackages ? (import ./pkgs.nix { inherit sources; }).smosReleasePackages }: { lib, pkgs, config, ... }: with lib; @@ -63,7 +63,7 @@ in }; script = '' - ${smosReleasePackages.smos-server-gen}/bin/smos-server-end-to-end-test + ${smos-server-gen}/bin/smos-server-end-to-end-test ''; serviceConfig = { diff --git a/nix/home-manager-module.nix b/nix/home-manager-module.nix index cc222b572..512aaed03 100644 --- a/nix/home-manager-module.nix +++ b/nix/home-manager-module.nix @@ -1,3 +1,4 @@ +{ smosReleasePackages }: { lib , pkgs , config @@ -17,7 +18,7 @@ in smosReleasePackages = mkOption { description = "The smosPackages attribute defined in the nix/overlay.nix file in the smos repository."; type = types.attrs; - default = (import ./pkgs.nix { }).smosReleasePackages; + default = smosReleasePackages; }; config = mkOption { description = "The contents of the config file, as an attribute set. This will be translated to Yaml and put in the right place along with the rest of the options defined in this submodule."; @@ -59,10 +60,16 @@ in description = "The username to use when logging into the sync server"; }; password = mkOption { - type = types.str; + type = types.nullOr types.str; + default = null; example = "hunter12"; description = "The password to use when logging into the sync server"; }; + password-file = mkOption { + type = types.nullOr types.str; + default = null; + description = "The password file to use when logging into the sync server"; + }; }; }); default = null; @@ -90,11 +97,16 @@ in description = "The destination file within the workflow directory"; }; source = mkOption { - type = types.str; + type = types.nullOr types.str; default = null; example = "https://calendar.google.com/calendar/ical/xxx.xxxxxxxxx%40gmail.com/private-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/basic.ics"; description = "The url to download the calendar from"; }; + source-file = mkOption { + type = types.nullOr types.str; + default = null; + description = "The file containing the url to download the calendar from"; + }; }; }); }; @@ -152,6 +164,25 @@ in }); default = null; }; + github = mkOption { + description = "Desktop notifications"; + type = types.nullOr (types.submodule { + options = { + enable = mkEnableOption "Smos github activation"; + oauth-token = mkOption { + type = types.nullOr types.str; + default = null; + description = "The oauth-token to use when logging into the sync server"; + }; + oauth-token-file = mkOption { + type = types.nullOr types.str; + default = null; + description = "The oauth-token file to use when logging into the sync server"; + }; + }; + }); + default = null; + }; }; config = let @@ -225,6 +256,7 @@ in server-url = cfg.sync.server-url; username = cfg.sync.username; password = cfg.sync.password; + password-file = cfg.sync.password-file; }; }; @@ -390,13 +422,14 @@ in packages = with cfg.smosReleasePackages; [ smos smos-archive - smos-calendar-import smos-query - smos-scheduler smos-single - smos-sync-client - smos-github - ] ++ optionals (cfg.notify.enable or false) [ smos-notify pkgs.libnotify ]; + ] + ++ optional (cfg.sync.enable or false) smos-sync-client + ++ optional (cfg.calendar.enable or false) smos-calendar-import + ++ optional (cfg.scheduler.enable or false) smos-scheduler + ++ optionals (cfg.notify.enable or false) [ smos-notify pkgs.libnotify ] + ++ optional (cfg.github.enable or false) smos-github; in mkIf (cfg.enable or false) { diff --git a/nix/merge-lists-recursively.nix b/nix/merge-lists-recursively.nix index c3f722641..5e7269063 100644 --- a/nix/merge-lists-recursively.nix +++ b/nix/merge-lists-recursively.nix @@ -3,7 +3,7 @@ attrList: lib.fold ( x: y: - lib.recursiveUpdate x y + lib.recursiveUpdate x y ) { } attrList diff --git a/nix/nixos-module.nix b/nix/nixos-module.nix index d52fe4cb0..0a5af9be4 100644 --- a/nix/nixos-module.nix +++ b/nix/nixos-module.nix @@ -1,9 +1,10 @@ +{ smos-docs-site +, smos-server +, smos-web-server +, looper +}: { envname -, sources ? import ./sources.nix -, pkgs ? import ./pkgs.nix { inherit sources; } -, smosReleasePackages ? pkgs.smosReleasePackages }: - { lib, pkgs, config, ... }: with lib; let @@ -11,7 +12,7 @@ let mergeListRecursively = pkgs.callPackage ./merge-lists-recursively.nix { }; - mkLooperOption = pkgs.callPackage (sources.looper + "/nix/looper-option.nix") { }; + mkLooperOption = looper.passthru.mkLooperOption; in { options.services.smos."${envname}" = @@ -67,7 +68,7 @@ in pkg = mkOption { description = "The docs site package"; type = types.package; - default = smosReleasePackages.smos-docs-site; + default = smos-docs-site; }; }; }); @@ -145,7 +146,7 @@ in pkg = mkOption { description = "The docs server package"; type = types.package; - default = smosReleasePackages.smos-server; + default = smos-server; }; monetisation = mkOption { description = "Monetisation settings for the API server"; @@ -246,7 +247,7 @@ in pkg = mkOption { description = "The web server package"; type = types.package; - default = smosReleasePackages.smos-web-server; + default = smos-web-server; }; }; }); diff --git a/nix/overlay.nix b/nix/overlay.nix index ce072745f..8b84b100b 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -1,16 +1,17 @@ -{ sources ? import ./sources.nix -}: -final: previous: +final: prev: with final.lib; +with final.haskell.lib; let - isMacos = builtins.currentSystem == "x86_64-darwin"; + stripe-spec = builtins.fetchGit { + url = "https://github.com/stripe/openapi"; + rev = "c48cf54aab65f4966ba285bdfaf86ed52f5fb70c"; + }; - generateOpenAPIClient = import (sources.openapi-code-generator + "/nix/generate-client.nix") { pkgs = final; }; - generatedStripe = generateOpenAPIClient { + generatedStripe = final.generateOpenAPIClient { name = "smos-stripe-client"; configFile = ../stripe-client-gen.yaml; - src = sources.stripe-spec + "/openapi/spec3.yaml"; + src = stripe-spec + "/openapi/spec3.yaml"; }; in { @@ -36,240 +37,30 @@ in }; in genAttrs castNames castDerivation; - smosPackages = with final.haskell.lib; - let - ownPkg = name: src: - overrideCabal (final.haskellPackages.callCabal2nixWithOptions name src "--no-hpack" { }) ( - old: { - buildDepends = (old.buildDepends or [ ]) ++ [ - final.haskellPackages.autoexporter - ]; - doBenchmark = true; - enableLibraryProfiling = false; - enableExecutableProfiling = false; - doCheck = false; - buildFlags = (old.buildFlags or [ ]) ++ [ - "--ghc-options=-Wincomplete-uni-patterns" - "--ghc-options=-Wincomplete-record-updates" - "--ghc-options=-Wpartial-fields" - "--ghc-options=-Widentities" - "--ghc-options=-Wredundant-constraints" - "--ghc-options=-Wcpp-undef" - "--ghc-options=-Wunused-packages" - ]; - # Ugly hack because we can't just add flags to the 'test' invocation. - # Show test output as we go, instead of all at once afterwards. - testTarget = (old.testTarget or "") + " --show-details=direct"; - } - ); - smosPkg = name: buildStrictly (ownPkg name (final.gitignoreSource (../. + "/${name}"))); - smosPkgWithComp = - exeName: name: - generateOptparseApplicativeCompletion exeName (smosPkg name); - smosPkgWithOwnComp = name: smosPkgWithComp name name; - withLinksChecked = exeName: pkg: - overrideCabal pkg (old: { - postInstall = '' - ${old.postInstall or ""} - - $out/bin/${exeName} & - sleep 1 - ${final.linkcheck}/bin/linkcheck http://localhost:8080 --fetchers 2 --log-level Info --check-fragments - ${final.seocheck}/bin/seocheck http://localhost:8080 --fetchers 2 --log-level Info - ${final.killall}/bin/killall ${exeName} - ''; - }); - withStaticResources = pkg: resources: overrideCabal pkg ( - old: - { - preConfigure = - let - copyResource = path: resource: - '' - local path="${path}" - mkdir --parents $(dirname "''$path") - ln -s ${resource} "''$path" - ''; - copyScript = concatStringsSep "\n" (mapAttrsToList copyResource resources); - in - '' - ${old.preConfigure or ""} - ${copyScript} - ''; - } - ); - - stylesheet = final.stdenv.mkDerivation { - name = "site-stylesheet.css"; - src = ../smos-web-style/style/mybulma.scss; - buildCommand = '' - # Dependency submodules are fetched manually here - # so that we don't have to fetch the submodules of smos - # when importing smos from derivation. - ln -s ${sources.bulma} bulma - ln -s ${sources.bulma-carousel} bulma-carousel - ln -s ${sources.bulma-pricingtable} bulma-pricingtable - - # The file we want to compile - # We need to copy this so that the relative path within it resolves to here instead of wherever we would link it from. - cp $src mybulma.scss - ${final.sass}/bin/scss \ - --sourcemap=none \ - mybulma.scss:index.css --style compressed - cp index.css $out - ''; - }; - smos-web-style = overrideCabal (smosPkg "smos-web-style") (old: { - preConfigure = '' - ${old.preConfigure or ""} - export STYLE_FILE=${stylesheet} - ''; - }); - docs-site-pkg = overrideCabal (smosPkgWithOwnComp "smos-docs-site") (old: { - preConfigure = '' - ${old.preConfigure or ""} - export NIXOS_MODULE_DOCS="${final.nixosModuleDocs}/share/doc/nixos/options.json" - export HOME_MANAGER_MODULE_DOCS="${final.homeManagerModuleDocs}/share/doc/nixos/options.json" - ''; - }); - smos-docs-site = withLinksChecked "smos-docs-site" ( - withStaticResources docs-site-pkg ( - { - "static/font-awesome.css" = builtins.fetchurl { - url = "https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"; - sha256 = "sha256:1gch64hq7xc9jqvs7npsil2hwsigdjnvf78v1vpgswq3rhjyp6kr"; - }; - "static/favicon.ico" = builtins.fetchurl { - url = "https://cs-syd.eu/logo/res/favicon.ico"; - sha256 = "sha256:0ahvcky6lrcpk2vd41558bjgh3x80mpkz4cl7smka534ypm5arz9"; - }; - "static/asciinema-player.js" = builtins.fetchurl { - url = "https://github.com/asciinema/asciinema-player/releases/download/v2.6.1/asciinema-player.js"; - sha256 = "sha256:092y2zl51z23jrl6mcqfxb64xaf9f2dx0j8kp69hp07m0935cz2p"; - }; - "static/asciinema-player.css" = builtins.fetchurl { - url = "https://github.com/asciinema/asciinema-player/releases/download/v2.6.1/asciinema-player.css"; - sha256 = "sha256:1yi45fdps5mjqdwjhqwwzvlwxb4j7fb8451z7s6sdqmi7py8dksj"; - }; - } // mapAttrs' (name: value: nameValuePair "content/casts/${name}.cast" value) final.smosCasts - ) - ); - smos-web-server = withStaticResources (smosPkgWithOwnComp "smos-web-server") ({ - "static/favicon.ico" = builtins.fetchurl { - url = "https://cs-syd.eu/logo/res/favicon.ico"; - sha256 = "sha256:0ahvcky6lrcpk2vd41558bjgh3x80mpkz4cl7smka534ypm5arz9"; - }; - "static/jquery.js" = builtins.fetchurl { - url = "https://code.jquery.com/jquery-3.3.1.min.js"; - sha256 = "sha256:1vq2bp290rhby5l09dv5khqwv3ysnzbddggbgk6m4hl9y9pl42hn"; - }; - "static/xterm.js" = builtins.fetchurl { - url = "https://cdn.jsdelivr.net/npm/xterm@4.8.1/lib/xterm.min.js"; - sha256 = "sha256:1vzha04sy8qhg833xb829pqd1ar7kpdxfklzc30xbb6wcwgrqh0j"; - }; - "static/xterm.css" = builtins.fetchurl { - url = "https://cdn.jsdelivr.net/npm/xterm@4.8.1/css/xterm.css"; - sha256 = "sha256:070zqrzizm5kdkkrfv19rhg8q4v9kr4hrfr544im6h5w5hy3i1j0"; - }; - "static/xterm-attach.js" = builtins.fetchurl { - url = "https://cdn.jsdelivr.net/npm/xterm-addon-attach@0.6.0/lib/xterm-addon-attach.min.js"; - sha256 = "sha256:1dpn6c8gc9xgq2xk7l0pikf59gw2h3c741p0hsiw4w3gysl93lkc"; - }; - "static/xterm-fit.js" = builtins.fetchurl { - url = "https://cdn.jsdelivr.net/npm/xterm-addon-fit@0.4.0/lib/xterm-addon-fit.min.js"; - sha256 = "sha256:1mpw2a2x96b26xfymz6prk4z41k45x9idfc7li48vam08d7x8rfn"; - }; - "static/asciinema-player.js" = builtins.fetchurl { - url = "https://github.com/asciinema/asciinema-player/releases/download/v2.6.1/asciinema-player.js"; - sha256 = "sha256:092y2zl51z23jrl6mcqfxb64xaf9f2dx0j8kp69hp07m0935cz2p"; - }; - "static/asciinema-player.css" = builtins.fetchurl { - url = "https://github.com/asciinema/asciinema-player/releases/download/v2.6.1/asciinema-player.css"; - sha256 = "sha256:1yi45fdps5mjqdwjhqwwzvlwxb4j7fb8451z7s6sdqmi7py8dksj"; - }; - "static/bulma-carousel.js" = builtins.fetchurl { - url = "https://cdn.jsdelivr.net/npm/bulma-carousel@4.0.3/dist/js/bulma-carousel.min.js"; - sha256 = "sha256:0cm7wj49qmbi9kp5hs3wc6vcr1h0d5h864pa5bc401nm5kppp958"; - }; - } // mapAttrs' (name: value: nameValuePair "casts/${name}.cast" value) final.smosCasts); - smos = overrideCabal (smosPkgWithOwnComp "smos") ( - old: { - postBuild = '' - ${old.postBuild or ""} - # Set up mime the types - mkdir -p $out/share/mime/packages - ln -s ${../mime/smos.mime-type} $out/share/mime/packages/smos.xml - - # Set up the .desktop files - mkdir -p $out/share/applications - ln -s ${../mime/smos.desktop} $out/share/applications/smos.desktop - ''; - } - ); - in - { - inherit smos; - "smos-data" = smosPkg "smos-data"; - "smos-data-gen" = smosPkg "smos-data-gen"; - "smos-cursor" = smosPkg "smos-cursor"; - "smos-cursor-gen" = smosPkg "smos-cursor-gen"; - "smos-report" = smosPkg "smos-report"; - "smos-report-gen" = smosPkg "smos-report-gen"; - "smos-report-cursor" = smosPkg "smos-report-cursor"; - "smos-report-cursor-gen" = smosPkg "smos-report-cursor-gen"; - "smos-query" = smosPkgWithOwnComp "smos-query"; - "smos-single" = smosPkgWithOwnComp "smos-single"; - "smos-scheduler" = smosPkgWithOwnComp "smos-scheduler"; - "smos-archive" = smosPkgWithOwnComp "smos-archive"; - "smos-calendar-import" = smosPkgWithOwnComp "smos-calendar-import"; - "smos-api" = smosPkg "smos-api"; - "smos-api-gen" = smosPkg "smos-api-gen"; - "smos-server" = smosPkgWithOwnComp "smos-server"; - "smos-server-gen" = smosPkg "smos-server-gen"; - "smos-client" = smosPkg "smos-client"; - "smos-sync-client" = smosPkgWithOwnComp "smos-sync-client"; - "smos-sync-client-gen" = smosPkg "smos-sync-client-gen"; - "smos-github" = smosPkgWithOwnComp "smos-github"; - "smos-notify" = smosPkgWithOwnComp "smos-notify"; - "smos-stripe-client" = generatedStripe.package; - inherit smos-web-style; - } // optionalAttrs (!isMacos) { - inherit smos-web-server; - inherit smos-docs-site; - }; - - smosHoogle = final.buildEnv { - name = "hoogle"; - paths = [ (final.haskellPackages.ghcWithHoogle (_: final.lib.attrValues final.smosPackages)) ]; - }; - # Turn off test suites on macos because they generate random - # filepaths and that fails for some reason that I cannot investigate - # because I don't own any apple products. smosReleasePackages = mapAttrs - (_: pkg: final.haskell.lib.justStaticExecutables - (if isMacos - then pkg else final.haskell.lib.doCheck pkg)) - final.smosPackages; + (_: pkg: justStaticExecutables (doCheck pkg)) + final.haskellPackages.smosPackages; smosRelease = final.symlinkJoin { name = "smos-release"; - paths = final.lib.attrValues final.smosReleasePackages; + paths = attrValues final.smosReleasePackages; }; nixosModuleDocs = let - eval = import (final.path + "/nixos/lib/eval-config.nix") { + smos-module = import ./nixos-module.nix + { + inherit (final.smosReleasePackages) smos-docs-site smos-server smos-web-server; + inherit (final.haskellPackages) looper; + } + { + envname = "production"; + }; + eval = final.evalNixOSConfig { pkgs = final; - modules = [ - (import ./nixos-module.nix { - inherit sources; - pkgs = final; - inherit (final) smosReleasePackages; - envname = "production"; - }) - ]; + modules = [ smos-module ]; }; in (final.nixosOptionsDoc { @@ -278,16 +69,17 @@ in homeManagerModuleDocs = let - eval = import (final.path + "/nixos/lib/eval-config.nix") { + smos-module = args@{ pkgs, config, lib, ... }: (import ./home-manager-module.nix) { inherit (final) smosReleasePackages; } ( + final.lib.recursiveUpdate args { + config.xdg.dataHome = "/home/user/.local/share"; + config.home.homeDirectory = "/home/user"; + } + ); + eval = final.evalNixOSConfig { pkgs = final; modules = [ { config._module.check = false; } - (args@{ pkgs, config, lib, ... }: (import ./home-manager-module.nix) ( - final.lib.recursiveUpdate args { - config.xdg.dataHome = "/home/user/.local/share"; - config.home.homeDirectory = "/home/user"; - } - )) + smos-module ]; }; in @@ -295,80 +87,271 @@ in options = eval.options; }).optionsJSON; - generatedSmosStripeCode = generatedStripe.code; + generatedSmosStripeCode = generatedStripe; haskellPackages = - previous.haskellPackages.override ( - old: - { - overrides = - final.lib.composeExtensions - ( - old.overrides or ( - _: - _: - { } - ) - ) - ( - self: super: with final.haskell.lib; - { - zip = dontCheck (enableCabalFlag (super.zip.override { bzlib-conduit = null; }) "disable-bzip2"); - iCalendar = self.callCabal2nix "iCalendar" - ( - builtins.fetchGit { - url = "https://github.com/NorfairKing/iCalendar"; - rev = "e08c16dceaab4d15b0f00860512018bc64791f07"; - } - ) - { }; - template-haskell-reload = self.callCabal2nix "template-haskell-reload" - ( - sources.template-haskell-reload - + "/template-haskell-reload" - ) - { }; - yesod-autoreload = self.callCabal2nix "yesod-autoreload" sources.yesod-autoreload { }; + prev.haskellPackages.override (old: { + overrides = final.lib.composeExtensions (old.overrides or (_: _: { })) ( + self: super: + let + smosPackages = + let + ownPkg = name: src: + overrideCabal (self.callPackage src { }) (old: { + buildDepends = (old.buildDepends or [ ]) ++ [ + final.haskellPackages.autoexporter + ]; + doBenchmark = true; + enableLibraryProfiling = false; + enableExecutableProfiling = false; + doCheck = false; + buildFlags = (old.buildFlags or [ ]) ++ [ + "--ghc-options=-Wincomplete-uni-patterns" + "--ghc-options=-Wincomplete-record-updates" + "--ghc-options=-Wpartial-fields" + "--ghc-options=-Widentities" + "--ghc-options=-Wredundant-constraints" + "--ghc-options=-Wcpp-undef" + "--ghc-options=-Wunused-packages" + ]; + # Ugly hack because we can't just add flags to the 'test' invocation. + # Show test output as we go, instead of all at once afterwards. + testTarget = (old.testTarget or "") + " --show-details=direct"; + }); + smosPkg = name: buildStrictly (ownPkg name (../. + "/${name}")); + smosPkgWithComp = exeName: name: generateOptparseApplicativeCompletion exeName (smosPkg name); + smosPkgWithOwnComp = name: smosPkgWithComp name name; + withLinksChecked = exeName: pkg: + overrideCabal pkg (old: { + postInstall = '' + ${old.postInstall or ""} - # These are turned off for the same reason as the local packages tests - dirforest = if isMacos then dontCheck super.dirforest else super.dirforest; - genvalidity-dirforest = if isMacos then dontCheck super.genvalidity-dirforest else super.genvalidity-dirforest; - cursor-dirforest = if isMacos then dontCheck super.cursor-dirforest else super.cursor-dirforest; - brick = self.callCabal2nix "brick" - ( - builtins.fetchTarball { - url = "https://hackage.haskell.org/package/brick-1.1/brick-1.1.tar.gz"; - sha256 = "0fgpp8bp5pywagbvpamfqsg0jmv09fljfinp4n59vpaavpnq3ak4"; - } - ) - { }; - bimap = self.callCabal2nix "bimap" - ( - builtins.fetchTarball { - url = "https://hackage.haskell.org/package/bimap-0.5.0/bimap-0.5.0.tar.gz"; - sha256 = "1p1bqvkbzjkwhrhhwcx0d4j52pa7287jdh45c8xzgksh1z33xg55"; - } - ) - { }; - text-zipper = self.callCabal2nix "text-zipper" - ( - builtins.fetchTarball { - url = "https://hackage.haskell.org/package/text-zipper-0.12/text-zipper-0.12.tar.gz"; - sha256 = "1jizvba1x91ik8770qgni3494if95wk0zxbdxj6y8lmpw4gd8vrz"; - } - ) - { }; - vty = self.callCabal2nix "vty" - ( - builtins.fetchTarball { - url = "https://hackage.haskell.org/package/vty-5.36/vty-5.36.tar.gz"; - sha256 = "05gnrp2qyc6199s9m2y28sxszv4h03y6nwf5j42vbgj2vn3k71cq"; - } + $out/bin/${exeName} & + sleep 1 + ${final.linkcheck}/bin/linkcheck http://localhost:8080 --fetchers 2 --log-level Info --check-fragments + ${final.seocheck}/bin/seocheck http://localhost:8080 --fetchers 2 --log-level Info + ${final.killall}/bin/killall ${exeName} + ''; + }); + withStaticResources = pkg: resources: overrideCabal pkg ( + old: + { + preConfigure = + let + copyResource = path: resource: + '' + local path="${path}" + mkdir --parents $(dirname "''$path") + ln -s ${resource} "''$path" + ''; + copyScript = concatStringsSep "\n" (mapAttrsToList copyResource resources); + in + '' + ${old.preConfigure or ""} + ${copyScript} + ''; + } + ); + + bulma = builtins.fetchGit { + url = "https://github.com/jgthms/bulma"; + rev = "c02757cd3043a4b30231c72dd01cd735c3b3672c"; + }; + bulma-carousel = builtins.fetchGit { + url = "https://github.com/Wikiki/bulma-carousel"; + rev = "71e38451f429af74aa8dd6c0d69ce9dd626f87f6"; + }; + bulma-pricingtable = builtins.fetchGit { + url = "https://github.com/Wikiki/bulma-pricingtable"; + rev = "25ef9a4e97afd2da9bd92d3e1c83fbd0caf91102"; + }; + + stylesheet = final.stdenv.mkDerivation { + name = "site-stylesheet.css"; + src = ../smos-web-style/style/mybulma.scss; + buildCommand = '' + # Dependency submodules are fetched manually here + # so that we don't have to fetch the submodules of smos + # when importing smos from derivation. + ln -s ${bulma} bulma + ln -s ${bulma-carousel} bulma-carousel + ln -s ${bulma-pricingtable} bulma-pricingtable + + # The file we want to compile + # We need to copy this so that the relative path within it resolves to here instead of wherever we would link it from. + cp $src mybulma.scss + ${final.sass}/bin/scss \ + --sourcemap=none \ + mybulma.scss:index.css --style compressed + cp index.css $out + ''; + }; + smos-web-style = overrideCabal (smosPkg "smos-web-style") (old: { + preConfigure = '' + ${old.preConfigure or ""} + export STYLE_FILE=${stylesheet} + ''; + }); + docs-site-pkg = overrideCabal (smosPkgWithOwnComp "smos-docs-site") (old: { + preConfigure = '' + ${old.preConfigure or ""} + export NIXOS_MODULE_DOCS="${final.nixosModuleDocs}/share/doc/nixos/options.json" + export HOME_MANAGER_MODULE_DOCS="${final.homeManagerModuleDocs}/share/doc/nixos/options.json" + ''; + }); + smos-docs-site = withLinksChecked "smos-docs-site" ( + withStaticResources docs-site-pkg ( + { + "static/font-awesome.css" = builtins.fetchurl { + url = "https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"; + sha256 = "sha256:1gch64hq7xc9jqvs7npsil2hwsigdjnvf78v1vpgswq3rhjyp6kr"; + }; + "static/favicon.ico" = builtins.fetchurl { + url = "https://cs-syd.eu/logo/res/favicon.ico"; + sha256 = "sha256:0ahvcky6lrcpk2vd41558bjgh3x80mpkz4cl7smka534ypm5arz9"; + }; + "static/asciinema-player.js" = builtins.fetchurl { + url = "https://github.com/asciinema/asciinema-player/releases/download/v2.6.1/asciinema-player.js"; + sha256 = "sha256:092y2zl51z23jrl6mcqfxb64xaf9f2dx0j8kp69hp07m0935cz2p"; + }; + "static/asciinema-player.css" = builtins.fetchurl { + url = "https://github.com/asciinema/asciinema-player/releases/download/v2.6.1/asciinema-player.css"; + sha256 = "sha256:1yi45fdps5mjqdwjhqwwzvlwxb4j7fb8451z7s6sdqmi7py8dksj"; + }; + } // mapAttrs' (name: value: nameValuePair "content/casts/${name}.cast" value) final.smosCasts ) - { }; + ); + smos-web-server = withStaticResources (smosPkgWithOwnComp "smos-web-server") ({ + "static/favicon.ico" = builtins.fetchurl { + url = "https://cs-syd.eu/logo/res/favicon.ico"; + sha256 = "sha256:0ahvcky6lrcpk2vd41558bjgh3x80mpkz4cl7smka534ypm5arz9"; + }; + "static/jquery.js" = builtins.fetchurl { + url = "https://code.jquery.com/jquery-3.3.1.min.js"; + sha256 = "sha256:1vq2bp290rhby5l09dv5khqwv3ysnzbddggbgk6m4hl9y9pl42hn"; + }; + "static/xterm.js" = builtins.fetchurl { + url = "https://cdn.jsdelivr.net/npm/xterm@4.8.1/lib/xterm.min.js"; + sha256 = "sha256:1vzha04sy8qhg833xb829pqd1ar7kpdxfklzc30xbb6wcwgrqh0j"; + }; + "static/xterm.css" = builtins.fetchurl { + url = "https://cdn.jsdelivr.net/npm/xterm@4.8.1/css/xterm.css"; + sha256 = "sha256:070zqrzizm5kdkkrfv19rhg8q4v9kr4hrfr544im6h5w5hy3i1j0"; + }; + "static/xterm-attach.js" = builtins.fetchurl { + url = "https://cdn.jsdelivr.net/npm/xterm-addon-attach@0.6.0/lib/xterm-addon-attach.min.js"; + sha256 = "sha256:1dpn6c8gc9xgq2xk7l0pikf59gw2h3c741p0hsiw4w3gysl93lkc"; + }; + "static/xterm-fit.js" = builtins.fetchurl { + url = "https://cdn.jsdelivr.net/npm/xterm-addon-fit@0.4.0/lib/xterm-addon-fit.min.js"; + sha256 = "sha256:1mpw2a2x96b26xfymz6prk4z41k45x9idfc7li48vam08d7x8rfn"; + }; + "static/asciinema-player.js" = builtins.fetchurl { + url = "https://github.com/asciinema/asciinema-player/releases/download/v2.6.1/asciinema-player.js"; + sha256 = "sha256:092y2zl51z23jrl6mcqfxb64xaf9f2dx0j8kp69hp07m0935cz2p"; + }; + "static/asciinema-player.css" = builtins.fetchurl { + url = "https://github.com/asciinema/asciinema-player/releases/download/v2.6.1/asciinema-player.css"; + sha256 = "sha256:1yi45fdps5mjqdwjhqwwzvlwxb4j7fb8451z7s6sdqmi7py8dksj"; + }; + "static/bulma-carousel.js" = builtins.fetchurl { + url = "https://cdn.jsdelivr.net/npm/bulma-carousel@4.0.3/dist/js/bulma-carousel.min.js"; + sha256 = "sha256:0cm7wj49qmbi9kp5hs3wc6vcr1h0d5h864pa5bc401nm5kppp958"; + }; + } // mapAttrs' (name: value: nameValuePair "casts/${name}.cast" value) final.smosCasts); + smos = overrideCabal (smosPkgWithOwnComp "smos") ( + old: { + postBuild = '' + ${old.postBuild or ""} + # Set up mime the types + mkdir -p $out/share/mime/packages + ln -s ${../mime/smos.mime-type} $out/share/mime/packages/smos.xml + + # Set up the .desktop files + mkdir -p $out/share/applications + ln -s ${../mime/smos.desktop} $out/share/applications/smos.desktop + ''; + } + ); + in + { + inherit smos; + "smos-data" = smosPkg "smos-data"; + "smos-data-gen" = smosPkg "smos-data-gen"; + "smos-cursor" = smosPkg "smos-cursor"; + "smos-cursor-gen" = smosPkg "smos-cursor-gen"; + "smos-report" = smosPkg "smos-report"; + "smos-report-gen" = smosPkg "smos-report-gen"; + "smos-report-cursor" = smosPkg "smos-report-cursor"; + "smos-report-cursor-gen" = smosPkg "smos-report-cursor-gen"; + "smos-query" = smosPkgWithOwnComp "smos-query"; + "smos-single" = smosPkgWithOwnComp "smos-single"; + "smos-scheduler" = smosPkgWithOwnComp "smos-scheduler"; + "smos-archive" = smosPkgWithOwnComp "smos-archive"; + "smos-calendar-import" = smosPkgWithOwnComp "smos-calendar-import"; + "smos-api" = smosPkg "smos-api"; + "smos-api-gen" = smosPkg "smos-api-gen"; + "smos-server" = smosPkgWithOwnComp "smos-server"; + "smos-server-gen" = smosPkg "smos-server-gen"; + "smos-client" = smosPkg "smos-client"; + "smos-sync-client" = smosPkgWithOwnComp "smos-sync-client"; + "smos-sync-client-gen" = smosPkg "smos-sync-client-gen"; + "smos-github" = smosPkgWithOwnComp "smos-github"; + "smos-notify" = smosPkgWithOwnComp "smos-notify"; + "smos-stripe-client" = self.callPackage (final.generatedSmosStripeCode + "/default.nix") { }; + inherit smos-web-style; + inherit smos-web-server; + inherit smos-docs-site; + }; + in + { + inherit smosPackages; + zip = dontCheck (enableCabalFlag (super.zip.override { bzlib-conduit = null; }) "disable-bzip2"); + iCalendar = self.callCabal2nix "iCalendar" + ( + builtins.fetchGit { + url = "https://github.com/NorfairKing/iCalendar"; + rev = "e08c16dceaab4d15b0f00860512018bc64791f07"; + } + ) + { }; - } // final.smosPackages - ); - } + # These are turned off for the same reason as the local packages tests + brick = self.callCabal2nix "brick" + ( + builtins.fetchTarball { + url = "https://hackage.haskell.org/package/brick-1.1/brick-1.1.tar.gz"; + sha256 = "0fgpp8bp5pywagbvpamfqsg0jmv09fljfinp4n59vpaavpnq3ak4"; + } + ) + { }; + bimap = self.callCabal2nix "bimap" + ( + builtins.fetchTarball { + url = "https://hackage.haskell.org/package/bimap-0.5.0/bimap-0.5.0.tar.gz"; + sha256 = "1p1bqvkbzjkwhrhhwcx0d4j52pa7287jdh45c8xzgksh1z33xg55"; + } + ) + { }; + text-zipper = self.callCabal2nix "text-zipper" + ( + builtins.fetchTarball { + url = "https://hackage.haskell.org/package/text-zipper-0.12/text-zipper-0.12.tar.gz"; + sha256 = "1jizvba1x91ik8770qgni3494if95wk0zxbdxj6y8lmpw4gd8vrz"; + } + ) + { }; + vty = self.callCabal2nix "vty" + ( + builtins.fetchTarball { + url = "https://hackage.haskell.org/package/vty-5.36/vty-5.36.tar.gz"; + sha256 = "05gnrp2qyc6199s9m2y28sxszv4h03y6nwf5j42vbgj2vn3k71cq"; + } + ) + { }; + + } // smosPackages + ); + } ); } diff --git a/nix/pkgs.nix b/nix/pkgs.nix deleted file mode 100644 index 350789501..000000000 --- a/nix/pkgs.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ sources ? import ./sources.nix -}: -import sources.nixpkgs { - config.allowUnfree = true; - overlays = [ - (import (sources.sydtest + "/nix/overlay.nix")) - (import (sources.validity + "/nix/overlay.nix")) - (import (sources.safe-coloured-text + "/nix/overlay.nix")) - (import (sources.looper + "/nix/overlay.nix")) - (import (sources.typed-uuid + "/nix/overlay.nix")) - (import (sources.pretty-relative-time + "/nix/overlay.nix")) - (import (sources.cursor + "/nix/overlay.nix")) - (import (sources.cursor-brick + "/nix/overlay.nix")) - (import (sources.dirforest + "/nix/overlay.nix")) - (import (sources.cursor-dirforest + "/nix/overlay.nix")) - (import (sources.autodocodec + "/nix/overlay.nix")) - (import (sources.fuzzy-time + "/nix/overlay.nix")) - (import (sources.cursor-fuzzy-time + "/nix/overlay.nix")) - (import (sources.mergeful + "/nix/overlay.nix")) - (import (sources.yesod-static-remote + "/nix/overlay.nix")) - (import (sources.autorecorder + "/nix/overlay.nix")) - (import (sources.linkcheck + "/nix/overlay.nix")) - (import (sources.seocheck + "/nix/overlay.nix")) - (import (sources.feedback + "/nix/overlay.nix")) - (final: previous: { niv = (import sources.niv { }).niv; }) - (final: previous: { inherit (import sources."gitignore.nix" { inherit (final) lib; }) gitignoreSource; }) - (import ./overlay.nix { - inherit sources; - }) - ]; -} diff --git a/nix/pre-commit.nix b/nix/pre-commit.nix deleted file mode 100644 index ef16f1cfc..000000000 --- a/nix/pre-commit.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ sources ? import ./sources.nix }: -let - pre-commit-hooks = import sources.pre-commit-hooks; -in -{ - run = pre-commit-hooks.run { - src = ../.; - hooks = { - hlint.enable = true; - hpack.enable = true; - nixpkgs-fmt.enable = true; - ormolu.enable = true; - statix.enable = true; - }; - settings.statix.ignore = [ - "sources.nix" - ]; - }; - tools = with pre-commit-hooks; [ - hlint - hpack - nixpkgs-fmt - ormolu - pre-commit - statix - ]; -} diff --git a/nix/sources.json b/nix/sources.json deleted file mode 100644 index 4bb7fb4df..000000000 --- a/nix/sources.json +++ /dev/null @@ -1,374 +0,0 @@ -{ - "autodocodec": { - "branch": "master", - "description": null, - "homepage": null, - "owner": "NorfairKing", - "repo": "autodocodec", - "rev": "49ff93b4e60a6725e49cb38db11bacffc7e0047c", - "sha256": "06v6qiv7p7khl792kb0zilvicp0q34a9rqwlpx6s10gsm2djkv1i", - "type": "tarball", - "url": "https://github.com/NorfairKing/autodocodec/archive/49ff93b4e60a6725e49cb38db11bacffc7e0047c.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "autorecorder": { - "branch": "master", - "description": "An automatic declarative ASCIInema recorder", - "homepage": null, - "owner": "NorfairKing", - "repo": "autorecorder", - "rev": "557cc2b6c8e9daa2dc5468a9bae6309216712e5d", - "sha256": "1nbj03b126l1dcy1djqi6sw3c61hsvxswz8lw3337xsgknhaikkk", - "type": "tarball", - "url": "https://github.com/NorfairKing/autorecorder/archive/557cc2b6c8e9daa2dc5468a9bae6309216712e5d.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "bulma": { - "branch": "master", - "description": "Modern CSS framework based on Flexbox", - "homepage": "https://bulma.io", - "owner": "jgthms", - "repo": "bulma", - "rev": "b3e32a77daca549a39c418b541f50e017efcadf9", - "sha256": "1wwdfjbs2gpch43iprdh29x20b00ajgj4bmf3vhg7knakzpby37n", - "type": "tarball", - "url": "https://github.com/jgthms/bulma/archive/b3e32a77daca549a39c418b541f50e017efcadf9.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "bulma-carousel": { - "branch": "master", - "description": "Display a carousel", - "homepage": null, - "owner": "Wikiki", - "repo": "bulma-carousel", - "rev": "71e38451f429af74aa8dd6c0d69ce9dd626f87f6", - "sha256": "13s7dahp1xb848n84s7hxj7s1ppkpmxlqj5x407k7s5yzprja0bx", - "type": "tarball", - "url": "https://github.com/Wikiki/bulma-carousel/archive/71e38451f429af74aa8dd6c0d69ce9dd626f87f6.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "bulma-pricingtable": { - "branch": "master", - "description": "Display a pricing table with Bulma", - "homepage": null, - "owner": "Wikiki", - "repo": "bulma-pricingtable", - "rev": "25ef9a4e97afd2da9bd92d3e1c83fbd0caf91102", - "sha256": "1p0ikarnjfjamyrwjx7sz67aqwld22mf2gwgcxpbvdhpf414kiik", - "type": "tarball", - "url": "https://github.com/Wikiki/bulma-pricingtable/archive/25ef9a4e97afd2da9bd92d3e1c83fbd0caf91102.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "cursor": { - "branch": "master", - "description": "Cursor data and manipulation", - "homepage": "", - "owner": "NorfairKing", - "repo": "cursor", - "rev": "5f18d58d1b34a752d24a94590c2cd35e8b6d557b", - "sha256": "1b0lffpzxzdhiz3532hz1yvwnm43xqik2cf165bmckicgqxaylpj", - "type": "tarball", - "url": "https://github.com/NorfairKing/cursor/archive/5f18d58d1b34a752d24a94590c2cd35e8b6d557b.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "cursor-brick": { - "branch": "master", - "description": "Brick widgets for cursors", - "homepage": null, - "owner": "NorfairKing", - "repo": "cursor-brick", - "rev": "5c1d1306632403a3dc11ddeda10deee932c0b307", - "sha256": "1kinwggmc9zdw4d3aszrvmf0baw4pf0hm040jgwv1j7731xwil3j", - "type": "tarball", - "url": "https://github.com/NorfairKing/cursor-brick/archive/5c1d1306632403a3dc11ddeda10deee932c0b307.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "cursor-dirforest": { - "branch": "master", - "description": "Directory forest cursor", - "homepage": null, - "owner": "NorfairKing", - "repo": "cursor-dirforest", - "rev": "6ad5b168e26eb4e647df9f007d812aaf59338d40", - "sha256": "0miy6chdyi8jjfivcpigyglhlx6x7f676n47vybjnpdhggv0kh2j", - "type": "tarball", - "url": "https://github.com/NorfairKing/cursor-dirforest/archive/6ad5b168e26eb4e647df9f007d812aaf59338d40.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "cursor-fuzzy-time": { - "branch": "master", - "description": null, - "homepage": null, - "owner": "NorfairKing", - "repo": "cursor-fuzzy-time", - "rev": "86830e3c14e1ec054e4423742eb34d1c49f9b8b0", - "sha256": "06l29kn9n0aj32qqsd6x518lqpa1609ddqprws63g1gr5w6ny97x", - "type": "tarball", - "url": "https://github.com/NorfairKing/cursor-fuzzy-time/archive/86830e3c14e1ec054e4423742eb34d1c49f9b8b0.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "dirforest": { - "branch": "master", - "description": null, - "homepage": null, - "owner": "NorfairKing", - "repo": "dirforest", - "rev": "69e8ae036b047fae105c1fe990e175a7572a3eba", - "sha256": "0d5gf7y46nrrrysmpmhfq7iij9xcpbiqp4bnzz09730zqfs40rm4", - "type": "tarball", - "url": "https://github.com/NorfairKing/dirforest/archive/69e8ae036b047fae105c1fe990e175a7572a3eba.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "feedback": { - "branch": "master", - "description": "Feedback loop manager", - "homepage": "", - "owner": "NorfairKing", - "repo": "feedback", - "rev": "38ae15aa6f8dde6ba6718afcc2633eda2029bb3d", - "sha256": "0idqz8hs1s52v8gcqlafrzmslv3fzdkm12njc8h01ax119i2s6jc", - "type": "tarball", - "url": "https://github.com/NorfairKing/feedback/archive/38ae15aa6f8dde6ba6718afcc2633eda2029bb3d.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "fuzzy-time": { - "branch": "master", - "description": null, - "homepage": "https://humanreadablemag.com/issues/2/articles/dealing-with-friday-the-13th", - "owner": "NorfairKing", - "repo": "fuzzy-time", - "rev": "98095d30b997a9af477390a6df573efc6b39e48c", - "sha256": "139s73c24dl20ig015ywgbngslivsp81zs5mc7s7yxn8la4p2860", - "type": "tarball", - "url": "https://github.com/NorfairKing/fuzzy-time/archive/98095d30b997a9af477390a6df573efc6b39e48c.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "gitignore.nix": { - "branch": "master", - "description": "Nix function for filtering local git sources", - "homepage": "", - "owner": "hercules-ci", - "repo": "gitignore.nix", - "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", - "sha256": "07vg2i9va38zbld9abs9lzqblz193vc5wvqd6h7amkmwf66ljcgh", - "type": "tarball", - "url": "https://github.com/hercules-ci/gitignore.nix/archive/a20de23b925fd8264fd7fad6454652e142fd7f73.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "linkcheck": { - "branch": "master", - "description": "A fast link checker for CI", - "homepage": null, - "owner": "NorfairKing", - "repo": "linkcheck", - "rev": "90c023208d6f0c49b3057d50b202cfbf92014729", - "sha256": "1nyc8sih7w81sxnv82c8kwwsmigfr19hy6f42dbzdf6am8wyjsv7", - "type": "tarball", - "url": "https://github.com/NorfairKing/linkcheck/archive/90c023208d6f0c49b3057d50b202cfbf92014729.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "looper": { - "branch": "master", - "description": "Run actions periodically", - "homepage": "http://hackage.haskell.org/package/looper", - "owner": "NorfairKing", - "repo": "looper", - "rev": "fd36d37becfa04fa4d7e00604e37c61817b6b62b", - "sha256": "0wk4nfnic6xhywr4kkfycl793f3q5mjz30k00s39jnmd26x726hc", - "type": "tarball", - "url": "https://github.com/NorfairKing/looper/archive/fd36d37becfa04fa4d7e00604e37c61817b6b62b.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "mergeful": { - "branch": "master", - "description": "Safely synchronise values with safe merge conflicts.", - "homepage": "http://hackage.haskell.org/package/mergeful", - "owner": "NorfairKing", - "repo": "mergeful", - "rev": "832092b8ed706bd3b045d5106f96715a6f4ddc4a", - "sha256": "09qaq99pwv64jw0khkas3g6n907q07p8d4mcig9s3y6pjx15sif6", - "type": "tarball", - "url": "https://github.com/NorfairKing/mergeful/archive/832092b8ed706bd3b045d5106f96715a6f4ddc4a.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "niv": { - "branch": "master", - "description": "Easy dependency management for Nix projects", - "homepage": "https://github.com/nmattia/niv", - "owner": "nmattia", - "repo": "niv", - "rev": "82e5cd1ad3c387863f0545d7591512e76ab0fc41", - "sha256": "090l219mzc0gi33i3psgph6s2pwsc8qy4lyrqjdj4qzkvmaj65a7", - "type": "tarball", - "url": "https://github.com/nmattia/niv/archive/82e5cd1ad3c387863f0545d7591512e76ab0fc41.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "nixpkgs": { - "branch": "nixos-22.05", - "description": "Nix Packages collection", - "homepage": "", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "fe76645aaf2fac3baaa2813fd0089930689c53b5", - "sha256": "1ic3r2d0xl54vf1lh4ggys1r3m6biq37k3anklv5pij1aiql1862", - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/fe76645aaf2fac3baaa2813fd0089930689c53b5.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "openapi-code-generator": { - "branch": "master", - "description": "Generate Haskell client code from an OpenAPI 3 specification", - "homepage": "", - "owner": "Haskell-OpenAPI-Code-Generator", - "repo": "Haskell-OpenAPI-Client-Code-Generator", - "rev": "af8435def9f3dff36180d1520b5c60200c532d2a", - "sha256": "0vwr6kpmvn2shhzyi61bnnq3i0yrb3py8sp844l9gdqk8wab7nwf", - "type": "tarball", - "url": "https://github.com/Haskell-OpenAPI-Code-Generator/Haskell-OpenAPI-Client-Code-Generator/archive/af8435def9f3dff36180d1520b5c60200c532d2a.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "pre-commit-hooks": { - "branch": "master", - "description": "Seamless integration of https://pre-commit.com git hooks with Nix.", - "homepage": "", - "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "rev": "2e4a708918e14fdbd534cc94aaa9470cd19b2464", - "sha256": "1k5rlrpvvyf65vzplh4haf0gs8ykpz5bcrilcdkvwqcd858zq838", - "type": "tarball", - "url": "https://github.com/cachix/pre-commit-hooks.nix/archive/2e4a708918e14fdbd534cc94aaa9470cd19b2464.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "pretty-relative-time": { - "branch": "master", - "description": null, - "homepage": "https://cs-syd.eu/posts/2019-12-14-pretty-relative-time", - "owner": "NorfairKing", - "repo": "pretty-relative-time", - "rev": "e3a97eea9539b22deb1e44405eb2d909866fa6f3", - "sha256": "077l2lid1xbx2lhvgsbr2k6zrw0hjv0z2y7l034f2lsp80iba3ir", - "type": "tarball", - "url": "https://github.com/NorfairKing/pretty-relative-time/archive/e3a97eea9539b22deb1e44405eb2d909866fa6f3.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "safe-coloured-text": { - "branch": "master", - "description": null, - "homepage": null, - "owner": "NorfairKing", - "repo": "safe-coloured-text", - "rev": "675cb01fce5f46718416d7746de5b856ed90a63f", - "sha256": "18lf28k51f24smkyba0dfv1hqz3jxfqr81w70zjvbw77z5q0vxf6", - "type": "tarball", - "url": "https://github.com/NorfairKing/safe-coloured-text/archive/675cb01fce5f46718416d7746de5b856ed90a63f.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "seocheck": { - "branch": "master", - "description": null, - "homepage": null, - "owner": "NorfairKing", - "repo": "seocheck", - "rev": "a6790f7de6ba252bbb4365ab1cc2aaeb0b243ccf", - "sha256": "0slivm1gyvl9c1md7svcqw4x503rdf1gs3xa5axv8a2vl2c19sv5", - "type": "tarball", - "url": "https://github.com/NorfairKing/seocheck/archive/a6790f7de6ba252bbb4365ab1cc2aaeb0b243ccf.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "smos-latest-release": { - "branch": "release", - "description": "A comprehensive self-management System", - "homepage": "https://smos.online", - "owner": "NorfairKing", - "repo": "smos", - "rev": "cf1669f353dce8c5d5fc2f378a89a9bc945f3f0b", - "sha256": "0gaal5ams6nwrfy2bg2wy08vklbj13xjpppbnamx9m65v1l12jf0", - "type": "tarball", - "url": "https://github.com/NorfairKing/smos/archive/cf1669f353dce8c5d5fc2f378a89a9bc945f3f0b.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "stripe-spec": { - "branch": "master", - "description": "An OpenAPI specification for the Stripe API. ", - "homepage": null, - "owner": "stripe", - "repo": "openapi", - "rev": "29fbd15caa93fb1e796e78eba7d5fa018dd9b5f3", - "sha256": "0k2vyfqzbpd66lryqcb4ydv56wzvgxcb57i4w3m3skzy9agwy0mg", - "type": "tarball", - "url": "https://github.com/stripe/openapi/archive/29fbd15caa93fb1e796e78eba7d5fa018dd9b5f3.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "sydtest": { - "branch": "development", - "description": "A modern testing framework for Haskell with good defaults and advanced testing features.", - "homepage": "", - "owner": "NorfairKing", - "repo": "sydtest", - "rev": "1050a44ab2e51a43fdbcda0b11bae122f501e716", - "sha256": "19krfkvwam5bnbglhyq68wdml8365n2764xd0nabxsm6k6aylgq7", - "type": "tarball", - "url": "https://github.com/NorfairKing/sydtest/archive/1050a44ab2e51a43fdbcda0b11bae122f501e716.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "template-haskell-reload": { - "branch": "master", - "description": "Load static data live during development, bake it into the executable for in production", - "homepage": "https://cs-syd.eu/posts/2021-02-27-watching-changes-in-yesod", - "owner": "NorfairKing", - "repo": "template-haskell-reload", - "rev": "c416550db3f353bad65980a8ecd9b3b81fa504bd", - "sha256": "1pqbd8vs0lbnx0vm7qz24846sprbk8fqfy195288zkgz871pi03i", - "type": "tarball", - "url": "https://github.com/NorfairKing/template-haskell-reload/archive/c416550db3f353bad65980a8ecd9b3b81fa504bd.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "typed-uuid": { - "branch": "master", - "description": "UUID with a phantom type", - "homepage": null, - "owner": "NorfairKing", - "repo": "typed-uuid", - "rev": "00fbc7e0380ab2ff72e8fd02323e76f13b7d5b59", - "sha256": "0rx63b7nwpl5svlqfyg2jmidl3a532n5v5r9lqpwq0i3lkqr5h7k", - "type": "tarball", - "url": "https://github.com/NorfairKing/typed-uuid/archive/00fbc7e0380ab2ff72e8fd02323e76f13b7d5b59.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "validity": { - "branch": "master", - "description": "Validity and validity-based testing", - "homepage": "https://www.youtube.com/watch?v=eIs9qNh17SM", - "owner": "NorfairKing", - "repo": "validity", - "rev": "657cf4bdc2731387abea6e707b88d381d5218616", - "sha256": "1ygj14nirm4nfbdcarkjbpykcf0l1c9dz08x8h374a301r3mwxya", - "type": "tarball", - "url": "https://github.com/NorfairKing/validity/archive/657cf4bdc2731387abea6e707b88d381d5218616.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "yesod-autoreload": { - "branch": "master", - "description": "Automatically have the browser reload a yesod site (without having to press the refresh button).", - "homepage": "https://cs-syd.eu/posts/2021-02-27-watching-changes-in-yesod", - "owner": "NorfairKing", - "repo": "yesod-autoreload", - "rev": "796def9af50cd7b053c9fb4a065c55603d4a8399", - "sha256": "04yqj1x6paha8cd71wax0zkgxh1v4qyar5qax56n5jq0hv9pvl3j", - "type": "tarball", - "url": "https://github.com/NorfairKing/yesod-autoreload/archive/796def9af50cd7b053c9fb4a065c55603d4a8399.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "yesod-static-remote": { - "branch": "master", - "description": "Turn runtime CDN usage into compile-time CDN usage.", - "homepage": "https://cs-syd.eu/posts/2019-07-14-yesod-static-remote", - "owner": "NorfairKing", - "repo": "yesod-static-remote", - "rev": "7eda644dc369e16c3591847f6c7cad30846bf6b0", - "sha256": "0lgls7zc1x0ysxghjah53ild24gnchdrhccpnkc0vf654yga3977", - "type": "tarball", - "url": "https://github.com/NorfairKing/yesod-static-remote/archive/7eda644dc369e16c3591847f6c7cad30846bf6b0.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - } -} diff --git a/nix/sources.nix b/nix/sources.nix deleted file mode 100644 index 3f841046a..000000000 --- a/nix/sources.nix +++ /dev/null @@ -1,177 +0,0 @@ -# This file has been generated by Niv. - -let - - # - # The fetchers. fetch_ fetches specs of type . - # - - fetch_file = pkgs: name: spec: - let - name' = sanitizeName name + "-src"; - in - if spec.builtin or true then - builtins_fetchurl { inherit (spec) url sha256; name = name'; } - else - pkgs.fetchurl { inherit (spec) url sha256; name = name'; }; - - fetch_tarball = pkgs: name: spec: - let - name' = sanitizeName name + "-src"; - in - if spec.builtin or true then - builtins_fetchTarball { name = name'; inherit (spec) url sha256; } - else - pkgs.fetchzip { name = name'; inherit (spec) url sha256; }; - - fetch_git = name: spec: - let - ref = - if spec ? ref then spec.ref else - if spec ? branch then "refs/heads/${spec.branch}" else - if spec ? tag then "refs/tags/${spec.tag}" else - abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!"; - in - builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; }; - - fetch_local = spec: spec.path; - - fetch_builtin-tarball = name: throw - ''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`. - $ niv modify ${name} -a type=tarball -a builtin=true''; - - fetch_builtin-url = name: throw - ''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`. - $ niv modify ${name} -a type=file -a builtin=true''; - - # - # Various helpers - # - - # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695 - sanitizeName = name: - ( - concatMapStrings (s: if builtins.isList s then "-" else s) - ( - builtins.split "[^[:alnum:]+._?=-]+" - ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name) - ) - ); - - # The set of packages used when specs are fetched using non-builtins. - mkPkgs = sources: system: - let - sourcesNixpkgs = - import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; }; - hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; - hasThisAsNixpkgsPath = == ./.; - in - if builtins.hasAttr "nixpkgs" sources - then sourcesNixpkgs - else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then - import { } - else - abort - '' - Please specify either (through -I or NIX_PATH=nixpkgs=...) or - add a package called "nixpkgs" to your sources.json. - ''; - - # The actual fetching function. - fetch = pkgs: name: spec: - - if ! builtins.hasAttr "type" spec then - abort "ERROR: niv spec ${name} does not have a 'type' attribute" - else if spec.type == "file" then fetch_file pkgs name spec - else if spec.type == "tarball" then fetch_tarball pkgs name spec - else if spec.type == "git" then fetch_git name spec - else if spec.type == "local" then fetch_local spec - else if spec.type == "builtin-tarball" then fetch_builtin-tarball name - else if spec.type == "builtin-url" then fetch_builtin-url name - else - abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; - - # If the environment variable NIV_OVERRIDE_${name} is set, then use - # the path directly as opposed to the fetched source. - replace = name: drv: - let - saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name; - ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}"; - in - if ersatz == "" then drv else - # this turns the string into an actual Nix path (for both absolute and - # relative paths) - if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}"; - - # Ports of functions for older nix versions - - # a Nix version of mapAttrs if the built-in doesn't exist - mapAttrs = builtins.mapAttrs or ( - f: set: with builtins; - listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)) - ); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 - range = first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 - stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269 - stringAsChars = f: s: concatStrings (map f (stringToCharacters s)); - concatMapStrings = f: list: concatStrings (map f list); - concatStrings = builtins.concatStringsSep ""; - - # https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331 - optionalAttrs = cond: as: if cond then as else { }; - - # fetchTarball version that is compatible between all the versions of Nix - builtins_fetchTarball = { url, name ? null, sha256 }@attrs: - let - inherit (builtins) lessThan nixVersion fetchTarball; - in - if lessThan nixVersion "1.12" then - fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) - else - fetchTarball attrs; - - # fetchurl version that is compatible between all the versions of Nix - builtins_fetchurl = { url, name ? null, sha256 }@attrs: - let - inherit (builtins) lessThan nixVersion fetchurl; - in - if lessThan nixVersion "1.12" then - fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) - else - fetchurl attrs; - - # Create the final "sources" from the config - mkSources = config: - mapAttrs - ( - name: spec: - if builtins.hasAttr "outPath" spec - then - abort - "The values in sources.json should not have an 'outPath' attribute" - else - spec // { outPath = replace name (fetch config.pkgs name spec); } - ) - config.sources; - - # The "config" used by the fetchers - mkConfig = - { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null - , sources ? if isNull sourcesFile then { } else builtins.fromJSON (builtins.readFile sourcesFile) - , system ? builtins.currentSystem - , pkgs ? mkPkgs sources system - }: rec { - # The sources, i.e. the attribute set of spec name to spec - inherit sources; - - # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers - inherit pkgs; - }; - -in -mkSources (mkConfig { }) // { __functor = _: settings: mkSources (mkConfig settings); } diff --git a/scripts/generate-stripe.sh b/scripts/generate-stripe.sh index 850491b50..c2f3cf047 100755 --- a/scripts/generate-stripe.sh +++ b/scripts/generate-stripe.sh @@ -1,3 +1,4 @@ sudo rm -rf smos-stripe-client -cp -rHL $(nix-build nix/pkgs.nix -A generatedSmosStripeCode) smos-stripe-client +nix build .#generatedSmosStripeCode +cp -rHL result smos-stripe-client sudo chmod -R +rwx smos-stripe-client diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 3e0012e62..000000000 --- a/shell.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ sources ? import ./nix/sources.nix -, pkgs ? import ./nix/pkgs.nix { inherit sources; } -, pre-commit ? import ./nix/pre-commit.nix { inherit sources; } -}: -pkgs.haskell.lib.buildStackProject { - name = "smos-nix-shell"; - buildInputs = with pkgs; [ - (import sources.niv { }).niv - asciinema - autoconf - bzip2 - feedback - git - haskellPackages.autoexporter - haskellPackages.autorecorder - hub - killall - sass - stripe-cli - xlibsWrapper - xorg.libXScrnSaver - xorg.libXrandr - xorg.libXrender - zlib - ] ++ pre-commit.tools; - shellHook = pre-commit.run.shellHook + pkgs.feedback.shellHook; -} diff --git a/smos-api-gen/default.nix b/smos-api-gen/default.nix new file mode 100644 index 000000000..ea5fc9111 --- /dev/null +++ b/smos-api-gen/default.nix @@ -0,0 +1,29 @@ +{ mkDerivation, aeson, base, bytestring, containers, criterion +, dirforest, genvalidity, genvalidity-bytestring +, genvalidity-criterion, genvalidity-mergeful, genvalidity-path +, genvalidity-sydtest, genvalidity-sydtest-aeson, genvalidity-text +, genvalidity-typed-uuid, genvalidity-uuid, lib, mergeful, path +, QuickCheck, semver, smos-api, smos-data, smos-data-gen +, smos-report, sydtest, sydtest-aeson, sydtest-discover, text, time +, typed-uuid, uuid +}: +mkDerivation { + pname = "smos-api-gen"; + version = "0.3.1"; + src = ./.; + libraryHaskellDepends = [ + base genvalidity genvalidity-bytestring genvalidity-mergeful + genvalidity-path genvalidity-text genvalidity-typed-uuid + genvalidity-uuid QuickCheck smos-api smos-data-gen text + ]; + testHaskellDepends = [ + aeson base bytestring containers dirforest genvalidity-sydtest + genvalidity-sydtest-aeson mergeful path semver smos-api smos-data + smos-report sydtest sydtest-aeson time typed-uuid uuid + ]; + testToolDepends = [ sydtest-discover ]; + benchmarkHaskellDepends = [ + base criterion genvalidity-criterion smos-api + ]; + license = lib.licenses.mit; +} diff --git a/smos-api/default.nix b/smos-api/default.nix new file mode 100644 index 000000000..75514a0b8 --- /dev/null +++ b/smos-api/default.nix @@ -0,0 +1,22 @@ +{ mkDerivation, aeson, autodocodec, base, base64-bytestring +, bytestring, cryptonite, deepseq, dirforest, hashable +, http-api-data, lib, memory, mergeful, mergeful-persistent +, password, password-instances, path, path-pieces, persistent +, semver, servant, servant-auth, servant-auth-server, smos-data +, smos-report, text, time, typed-uuid, uuid, validity +, validity-bytestring, validity-path, validity-text, validity-uuid +}: +mkDerivation { + pname = "smos-api"; + version = "0.5.0"; + src = ./.; + libraryHaskellDepends = [ + aeson autodocodec base base64-bytestring bytestring cryptonite + deepseq dirforest hashable http-api-data memory mergeful + mergeful-persistent password password-instances path path-pieces + persistent semver servant servant-auth servant-auth-server + smos-data smos-report text time typed-uuid uuid validity + validity-bytestring validity-path validity-text validity-uuid + ]; + license = lib.licenses.mit; +} diff --git a/smos-archive/default.nix b/smos-archive/default.nix new file mode 100644 index 000000000..01d41f254 --- /dev/null +++ b/smos-archive/default.nix @@ -0,0 +1,27 @@ +{ mkDerivation, autodocodec, base, bytestring, conduit, containers +, dirforest, envparse, exceptions, filepath, genvalidity-sydtest +, lib, monad-logger, mtl, optparse-applicative, path, path-io +, smos-data, smos-data-gen, smos-report, smos-report-gen, sydtest +, sydtest-discover, text, time, unliftio, validity +}: +mkDerivation { + pname = "smos-archive"; + version = "0.3.2"; + src = ./.; + isLibrary = true; + isExecutable = true; + libraryHaskellDepends = [ + autodocodec base bytestring conduit containers envparse exceptions + filepath monad-logger mtl optparse-applicative path path-io + smos-data smos-report text time unliftio validity + ]; + executableHaskellDepends = [ base ]; + testHaskellDepends = [ + base bytestring dirforest genvalidity-sydtest monad-logger path + path-io smos-data smos-data-gen smos-report smos-report-gen sydtest + time + ]; + testToolDepends = [ sydtest-discover ]; + license = lib.licenses.mit; + mainProgram = "smos-archive"; +} diff --git a/smos-calendar-import/default.nix b/smos-calendar-import/default.nix new file mode 100644 index 000000000..956d59ca8 --- /dev/null +++ b/smos-calendar-import/default.nix @@ -0,0 +1,35 @@ +{ mkDerivation, aeson, async, autodocodec, autodocodec-yaml, base +, bytestring, containers, data-default, envparse, genvalidity +, genvalidity-containers, genvalidity-sydtest +, genvalidity-sydtest-aeson, genvalidity-text, genvalidity-time +, http-client, http-client-tls, iCalendar, lib, mtl, network-uri +, optparse-applicative, path, path-io, QuickCheck, safe, smos-data +, smos-data-gen, smos-report, sydtest, sydtest-discover, text, time +, time-compat, validity, validity-containers, validity-text +, validity-time, yaml +}: +mkDerivation { + pname = "smos-calendar-import"; + version = "0.6.1"; + src = ./.; + isLibrary = true; + isExecutable = true; + libraryHaskellDepends = [ + aeson async autodocodec base bytestring containers data-default + envparse http-client http-client-tls iCalendar mtl network-uri + optparse-applicative path path-io safe smos-data smos-report text + time time-compat validity validity-containers validity-text + validity-time yaml + ]; + executableHaskellDepends = [ base ]; + testHaskellDepends = [ + autodocodec autodocodec-yaml base bytestring containers + data-default genvalidity genvalidity-containers genvalidity-sydtest + genvalidity-sydtest-aeson genvalidity-text genvalidity-time + iCalendar path path-io QuickCheck safe smos-data smos-data-gen + sydtest text time yaml + ]; + testToolDepends = [ sydtest-discover ]; + license = lib.licenses.mit; + mainProgram = "smos-calendar-import"; +} diff --git a/smos-calendar-import/src/Smos/Calendar/Import.hs b/smos-calendar-import/src/Smos/Calendar/Import.hs index 0d3e5fa54..47882c399 100644 --- a/smos-calendar-import/src/Smos/Calendar/Import.hs +++ b/smos-calendar-import/src/Smos/Calendar/Import.hs @@ -9,7 +9,6 @@ import Control.Concurrent.Async import Control.Monad import Data.Aeson (FromJSON, ToJSON) import Data.Default -import qualified Data.List.NonEmpty as NE import qualified Data.Text as T import qualified Data.Text.Encoding as TE import Data.Time @@ -58,7 +57,7 @@ smosCalendarImport = do let recurrenceLimit = addDays 30 today hereTZ <- getCurrentTimeZone man <- HTTP.newTlsManager - results <- forConcurrently (NE.toList setSources) $ \Source {..} -> do + results <- forConcurrently setSources $ \Source {..} -> do let originName = case sourceName of Just n -> n Nothing -> case sourceOrigin of diff --git a/smos-calendar-import/src/Smos/Calendar/Import/OptParse.hs b/smos-calendar-import/src/Smos/Calendar/Import/OptParse.hs index cdd0bd20e..21bcdd519 100644 --- a/smos-calendar-import/src/Smos/Calendar/Import/OptParse.hs +++ b/smos-calendar-import/src/Smos/Calendar/Import/OptParse.hs @@ -8,7 +8,10 @@ module Smos.Calendar.Import.OptParse where import Control.Monad +import qualified Data.ByteString as SB import Data.Maybe +import qualified Data.Text as T +import qualified Data.Text.Encoding as TE import Data.Version import qualified Env import Network.URI @@ -22,7 +25,6 @@ import Smos.Data import qualified Smos.Report.Config as Report import qualified Smos.Report.OptParse as Report import qualified System.Environment as System -import System.Exit getSettings :: IO Settings getSettings = do @@ -44,17 +46,24 @@ deriveSettings Flags {..} Environment {..} mConf = do flagDirectoryFlags envDirectoryEnvironment (confDirectoryConfiguration <$> mConf) - setSources <- case mc calendarImportConfSources of - Nothing -> die "No sources configured." - Just ss -> forM ss $ \SourceConfiguration {..} -> do - let sourceName = sourceConfName - sourceDestinationFile <- parseRelFile sourceConfDestinationFile - sourceOrigin <- case parseURI sourceConfOrigin of - Just uri -> pure $ WebOrigin uri - Nothing -> do - putStrLn $ "Couldn't parse into an URI, assuming it's a file: " <> sourceConfOrigin - FileOrigin <$> resolveFile' sourceConfOrigin - pure Source {..} + setSources <- fmap catMaybes $ + forM (maybe [] calendarImportConfSources (mConf >>= confCalendarImportConfiguration)) $ \SourceConfiguration {..} -> do + mOriginURIString <- case sourceConfOrigin of + Just uri -> pure $ Just uri + Nothing -> case sourceConfOriginFile of + Just uriFile -> Just . T.unpack . T.strip . TE.decodeUtf8 <$> SB.readFile uriFile + Nothing -> pure Nothing + case mOriginURIString of + Nothing -> pure Nothing + Just originURIString -> do + let sourceName = sourceConfName + sourceDestinationFile <- parseRelFile sourceConfDestinationFile + sourceOrigin <- case parseURI originURIString of + Just uri -> pure $ WebOrigin uri + Nothing -> do + putStrLn $ "Couldn't parse into an URI, assuming it's a file: " <> originURIString + FileOrigin <$> resolveFile' originURIString + pure (Just Source {..}) let setDebug = fromMaybe False $ flagDebug <|> envDebug <|> mc calendarImportConfDebug pure Settings {..} diff --git a/smos-calendar-import/src/Smos/Calendar/Import/OptParse/Types.hs b/smos-calendar-import/src/Smos/Calendar/Import/OptParse/Types.hs index 3ada97a25..b43ed695b 100644 --- a/smos-calendar-import/src/Smos/Calendar/Import/OptParse/Types.hs +++ b/smos-calendar-import/src/Smos/Calendar/Import/OptParse/Types.hs @@ -3,7 +3,6 @@ module Smos.Calendar.Import.OptParse.Types where import Autodocodec -import Data.List.NonEmpty (NonEmpty (..)) import Network.URI (URI) import Path import qualified Smos.Report.Config as Report @@ -35,7 +34,7 @@ instance HasCodec Configuration where <*> optionalFieldOrNull "calendar" "Calendar configuration" .= confCalendarImportConfiguration data CalendarImportConfiguration = CalendarImportConfiguration - { calendarImportConfSources :: !(Maybe (NonEmpty SourceConfiguration)), + { calendarImportConfSources :: ![SourceConfiguration], calendarImportConfDebug :: !(Maybe Bool) } deriving (Show, Eq) @@ -44,12 +43,13 @@ instance HasCodec CalendarImportConfiguration where codec = object "CalendarImportConfiguration" $ CalendarImportConfiguration - <$> optionalFieldOrNull "sources" "The sources to import from" .= calendarImportConfSources + <$> optionalFieldOrNullWithOmittedDefault "sources" [] "The sources to import from" .= calendarImportConfSources <*> optionalFieldOrNull "debug" "Show the internal structure of every event in its entry's contents." .= calendarImportConfDebug data SourceConfiguration = SourceConfiguration { sourceConfName :: !(Maybe String), - sourceConfOrigin :: !String, + sourceConfOrigin :: !(Maybe String), + sourceConfOriginFile :: !(Maybe FilePath), sourceConfDestinationFile :: !FilePath } deriving (Show, Eq) @@ -59,7 +59,7 @@ instance HasCodec SourceConfiguration where object "SourceConfiguration" $ SourceConfiguration <$> optionalFieldOrNull "name" "The name of the source" .= sourceConfName - <*> requiredFieldWith + <*> optionalFieldOrNullWith "source" ( codec [ "If you are using Google, you want to get the URL that has these labels:", @@ -70,11 +70,15 @@ instance HasCodec SourceConfiguration where ) "the url to fetch or file to import" .= sourceConfOrigin + <*> optionalFieldOrNull + "source-file" + "the file that contains the url to fetch or file to import" + .= sourceConfOriginFile <*> requiredField "destination" "The destination path within the workflow directory" .= sourceConfDestinationFile data Settings = Settings { setDirectorySettings :: !Report.DirectoryConfig, - setSources :: !(NonEmpty Source), + setSources :: ![Source], setDebug :: Bool } deriving (Show, Eq) diff --git a/smos-client/default.nix b/smos-client/default.nix new file mode 100644 index 000000000..c1635e204 --- /dev/null +++ b/smos-client/default.nix @@ -0,0 +1,20 @@ +{ mkDerivation, base, bytestring, cookie, deepseq, dirforest +, http-types, lib, microlens, path, pretty-show, semver, servant +, servant-auth-client, servant-auth-server, servant-client +, servant-client-core, smos-api, smos-data, smos-report, sydtest +, sydtest-discover, text, time +}: +mkDerivation { + pname = "smos-client"; + version = "0.5.1"; + src = ./.; + libraryHaskellDepends = [ + base bytestring cookie deepseq dirforest http-types microlens path + pretty-show semver servant servant-auth-client servant-auth-server + servant-client servant-client-core smos-api smos-data smos-report + text time + ]; + testHaskellDepends = [ base smos-api smos-data sydtest ]; + testToolDepends = [ sydtest-discover ]; + license = lib.licenses.mit; +} diff --git a/smos-cursor-gen/default.nix b/smos-cursor-gen/default.nix new file mode 100644 index 000000000..929098ea6 --- /dev/null +++ b/smos-cursor-gen/default.nix @@ -0,0 +1,30 @@ +{ mkDerivation, base, bytestring, criterion, cursor +, cursor-dirforest, cursor-dirforest-gen, cursor-fuzzy-time-gen +, cursor-gen, dirforest, genvalidity, genvalidity-criterion +, genvalidity-path, genvalidity-sydtest, genvalidity-sydtest-lens +, genvalidity-text, lib, path, path-io, QuickCheck, resourcet +, smos-cursor, smos-data, smos-data-gen, sydtest, sydtest-discover +}: +mkDerivation { + pname = "smos-cursor-gen"; + version = "0.2.1"; + src = ./.; + libraryHaskellDepends = [ + base cursor cursor-dirforest-gen cursor-fuzzy-time-gen cursor-gen + genvalidity genvalidity-text QuickCheck smos-cursor smos-data + smos-data-gen + ]; + testHaskellDepends = [ + base bytestring cursor cursor-dirforest cursor-fuzzy-time-gen + cursor-gen dirforest genvalidity-path genvalidity-sydtest + genvalidity-sydtest-lens path path-io QuickCheck resourcet + smos-cursor smos-data smos-data-gen sydtest + ]; + testToolDepends = [ sydtest-discover ]; + benchmarkHaskellDepends = [ + base criterion genvalidity-criterion smos-cursor smos-data + smos-data-gen + ]; + homepage = "https://github.com/NorfairKing/smos#readme"; + license = "unknown"; +} diff --git a/smos-cursor/default.nix b/smos-cursor/default.nix new file mode 100644 index 000000000..a878bd09a --- /dev/null +++ b/smos-cursor/default.nix @@ -0,0 +1,17 @@ +{ mkDerivation, base, containers, cursor, cursor-dirforest +, cursor-fuzzy-time, deepseq, dirforest, exceptions, filelock +, fuzzy-time, lib, microlens, path, path-io, resourcet +, smos-archive, smos-data, text, time, validity, validity-time +}: +mkDerivation { + pname = "smos-cursor"; + version = "0.5.0"; + src = ./.; + libraryHaskellDepends = [ + base containers cursor cursor-dirforest cursor-fuzzy-time deepseq + dirforest exceptions filelock fuzzy-time microlens path path-io + resourcet smos-archive smos-data text time validity validity-time + ]; + homepage = "https://github.com/NorfairKing/smos#readme"; + license = "unknown"; +} diff --git a/smos-data-gen/default.nix b/smos-data-gen/default.nix new file mode 100644 index 000000000..44048b727 --- /dev/null +++ b/smos-data-gen/default.nix @@ -0,0 +1,28 @@ +{ mkDerivation, aeson, autodocodec, autodocodec-yaml, base +, bytestring, containers, criterion, filepath, genvalidity +, genvalidity-containers, genvalidity-criterion +, genvalidity-sydtest, genvalidity-sydtest-aeson, genvalidity-text +, genvalidity-time, lib, path, path-io, QuickCheck, semver +, smos-data, sydtest, sydtest-discover, text, time +}: +mkDerivation { + pname = "smos-data-gen"; + version = "0.3.2"; + src = ./.; + libraryHaskellDepends = [ + base genvalidity genvalidity-containers genvalidity-text + genvalidity-time path-io QuickCheck semver smos-data sydtest text + time + ]; + testHaskellDepends = [ + aeson autodocodec autodocodec-yaml base bytestring containers + filepath genvalidity-sydtest genvalidity-sydtest-aeson path path-io + QuickCheck semver smos-data sydtest text time + ]; + testToolDepends = [ sydtest-discover ]; + benchmarkHaskellDepends = [ + base containers criterion genvalidity-containers + genvalidity-criterion path path-io smos-data + ]; + license = lib.licenses.mit; +} diff --git a/smos-data/default.nix b/smos-data/default.nix new file mode 100644 index 000000000..f20b0df31 --- /dev/null +++ b/smos-data/default.nix @@ -0,0 +1,16 @@ +{ mkDerivation, aeson, aeson-pretty, autodocodec, autodocodec-yaml +, base, bytestring, containers, deepseq, lib, microlens, path +, path-io, semver, text, time, unliftio, validity +, validity-containers, validity-text, validity-time, yaml +}: +mkDerivation { + pname = "smos-data"; + version = "0.5.0"; + src = ./.; + libraryHaskellDepends = [ + aeson aeson-pretty autodocodec autodocodec-yaml base bytestring + containers deepseq microlens path path-io semver text time unliftio + validity validity-containers validity-text validity-time yaml + ]; + license = lib.licenses.mit; +} diff --git a/smos-docs-site/content/pages/building-installation.markdown b/smos-docs-site/content/pages/building-installation.markdown index b9be37549..ad80050cf 100644 --- a/smos-docs-site/content/pages/building-installation.markdown +++ b/smos-docs-site/content/pages/building-installation.markdown @@ -13,3 +13,10 @@ It probably won't work on Windows as-is. (See [Issue 52](https://github.com/Norf * [Nix](/installation/nix) * [Windows](/installation/windows) * [NixOS](/installation/nixos) + + +If you'd like to try smos out _and_ you have `nix` installed, you can "just" run this: + +``` +nix run github:NorfairKing/smos +``` diff --git a/smos-docs-site/content/pages/development/contributing.markdown b/smos-docs-site/content/pages/development/contributing.markdown index 7053be6fb..e3886b739 100644 --- a/smos-docs-site/content/pages/development/contributing.markdown +++ b/smos-docs-site/content/pages/development/contributing.markdown @@ -17,8 +17,8 @@ description: An contribution guide for developers that are new to the smos proje ``` 1. We use Nix for CI and deployment. - Make sure you can run `nix-shell` as described in [the nix installation guide](/installation/nix). - This also ensures that the pre-commit hoosk are installed. + Make sure you can run `nix develop`. + This also ensures that the pre-commit hooks are installed. 1. We use stack for development. Make sure you can run `stack test smos` after following the steps in [the stack installation guide](/installation/stack). 1. Checkout the `development` branch: @@ -30,29 +30,29 @@ description: An contribution guide for developers that are new to the smos proje 1. Enter the nix shell ``` - $ nix-shell + $ nix develop ``` 1. Set up your feedback loop. When developing in a single smos package, you can use ``` - nix-shell $ stack test --pedantic --file-watch + nix $ stack test --pedantic --file-watch ``` When developing accross multiple smos packages, you can use ``` - nix-shell $ stack test --pedantic --file-watch --no-rerun-tests + nix $ stack test --pedantic --file-watch --no-rerun-tests ``` - Some feedback loops are provided, as you should have seen when you ran `nix-shell`. + Some feedback loops are provided, as you should have seen when you ran `nix develop`. You may want to check if those fit your needs first. 1. Optionally: Set up a local hoogle server to look up code documentation for smos or its dependencies: ``` - $(nix-build ci.nix -A hoogle)/bin/hoogle serve --local + nix $ hoogle serve --local ``` 1. Make your changes. @@ -60,10 +60,10 @@ description: An contribution guide for developers that are new to the smos proje 1. Make sure the following commands succeeds locally: ``` - nix-shell $ stack clean - nix-shell $ stack build --test --bench --no-run-benchmarks --pedantic` + nix $ stack clean + nix $ stack build --test --bench --no-run-benchmarks --pedantic` ``` -1. Make sure `nix-build ci.nix` succeeds locally. +1. Make sure `nix flake check` succeeds locally. 1. Create a pull request with `NorfairKing/development` as the base. diff --git a/smos-docs-site/content/pages/development/contributing/package-overview.markdown b/smos-docs-site/content/pages/development/contributing/package-overview.markdown index f66e6a749..4773b1ebc 100644 --- a/smos-docs-site/content/pages/development/contributing/package-overview.markdown +++ b/smos-docs-site/content/pages/development/contributing/package-overview.markdown @@ -16,7 +16,6 @@ smos : The smos TUI smos-single ; The smos-single tool; to make a single-task project smos-query : The smos-query tool; to query your workflow smos-archive : The smos-archive tool: to archive smos files -smos-convert-org : The smos-convert-org tool: to convert org-mode files to smos files smos-github : The smos-github tool: to integrate with GitHub efficiently. smos-scheduler : The smos-scheduler tool: to automate setting up recurring projects. smos-calendar-import : The calendar import tool: to import calendars in an ongoing manner diff --git a/smos-docs-site/content/pages/development/contributing/smos-docs-site.markdown b/smos-docs-site/content/pages/development/contributing/smos-docs-site.markdown index 4c54bef0d..03e1300bc 100644 --- a/smos-docs-site/content/pages/development/contributing/smos-docs-site.markdown +++ b/smos-docs-site/content/pages/development/contributing/smos-docs-site.markdown @@ -8,8 +8,8 @@ description: How to contribute to the Smos Documentation Site To contribute to the documentation site, use `feedback`: ``` -$ nix-shell -nix-shell $ feedback docs +$ nix develop +nix $ feedback docs ``` ## Contributing casts @@ -17,12 +17,11 @@ nix-shell $ feedback docs Contributing an screencast to the documentation site involves writing an `autorecorder` cast specification. This ensures that the casts are always showing the current version of the tools that they show off. -1. Install `autorecorder` [from source](https://github.com/NorfairKing/autorecorder) -2. Locate the cast spec files in `smos-docs-site/content/casts`. -3. Copy the example cast: `example.yaml` to create your new `mycast.yaml` specification. -4. Make the changes that you want. -5. Try out your cast using `autorecorder record mycast.yaml mycast.cast`. -6. Use your cast in the documentation site by embedding it like this: +1. Locate the cast spec files in `smos-docs-site/content/casts`. +1. Copy the example cast: `example.yaml` to create your new `mycast.yaml` specification. +1. Make the changes that you want. +1. Try out your cast using `autorecorder record mycast.yaml mycast.cast`. +1. Use your cast in the documentation site by embedding it like this: ``` html ImportSettings -> IO () githubImport Settings {..} ImportSettings {..} = do - case setGithubOauthToken of + case setGitHubOauthToken of Nothing -> putStrLn "WARNING: No OAUTH token configured. Some functionality may not work without it." Just _ -> pure () case parseGitHubUrl importSetUrl of Nothing -> die $ "Could not parse as a URL of a github issue or pull request:" <> importSetUrl Just gitHubUrl -> do projectsDir <- resolveDirProjectsDir setDirectorySettings - let mAuth = GitHub.OAuth . TE.encodeUtf8 <$> setGithubOauthToken + let mAuth = GitHub.OAuth . TE.encodeUtf8 <$> setGitHubOauthToken mDetails <- forM mAuth $ \auth -> fetchDetails auth gitHubUrl now <- getCurrentTime diff --git a/smos-github/src/Smos/GitHub/Command/List.hs b/smos-github/src/Smos/GitHub/Command/List.hs index 0da4807ac..074461cd2 100644 --- a/smos-github/src/Smos/GitHub/Command/List.hs +++ b/smos-github/src/Smos/GitHub/Command/List.hs @@ -40,7 +40,7 @@ import Text.Colour.Term githubList :: Settings -> IO () githubList Settings {..} = do wd <- resolveDirWorkflowDir setDirectorySettings - case setGithubOauthToken of + case setGitHubOauthToken of Nothing -> putStrLn "WARNING: No OAUTH token configured. Some functionality may not work without it." Just _ -> pure () trips <- @@ -51,7 +51,7 @@ githubList Settings {..} = do .| smosFileEntries .| C.concatMap (\(rf, e) -> (,,) rf e <$> parseEntryGitHubUrl e) -- C.concatMap generalises mapMaybe .| sinkList - let mAuth = OAuth . TE.encodeUtf8 <$> setGithubOauthToken + let mAuth = OAuth . TE.encodeUtf8 <$> setGitHubOauthToken report <- completeListReport mAuth trips putChunksLocale $ renderGitHubListReport setColourConfig report @@ -92,8 +92,8 @@ data Ball = BallInOurCourt | BallInTheirCourt fillInRow :: Maybe GitHub.Auth -> (Path Rel File, Entry, GitHubUrl) -> IO ListReportRow fillInRow mAuth (listReportRowPath, listReportRowEntry, listReportRowGitHubUrl) = do - let mGithub :: FromJSON result => GitHub.Request rw result -> IO (Maybe result) - mGithub req = case mAuth of + let mGitHub :: FromJSON result => GitHub.Request rw result -> IO (Maybe result) + mGitHub req = case mAuth of Nothing -> pure Nothing Just auth -> do errOrRes <- github auth req @@ -102,14 +102,14 @@ fillInRow mAuth (listReportRowPath, listReportRowEntry, listReportRowGitHubUrl) Right r -> Just r (listReportRowState, listReportRowMerged, mRemoteLastUpdate) <- case listReportRowGitHubUrl of PullRequestUrl o r i -> do - pr <- mGithub $ GitHub.pullRequestR o r i + pr <- mGitHub $ GitHub.pullRequestR o r i pure ( GitHub.pullRequestState <$> pr, pr >>= GitHub.pullRequestMergedAt, GitHub.pullRequestUpdatedAt <$> pr ) IssueUrl o r i -> do - iss <- mGithub $ GitHub.issueR o r i + iss <- mGitHub $ GitHub.issueR o r i pure ( GitHub.issueState <$> iss, Nothing, diff --git a/smos-github/src/Smos/GitHub/OptParse.hs b/smos-github/src/Smos/GitHub/OptParse.hs index 69289db76..109158c1e 100644 --- a/smos-github/src/Smos/GitHub/OptParse.hs +++ b/smos-github/src/Smos/GitHub/OptParse.hs @@ -8,6 +8,9 @@ module Smos.GitHub.OptParse where import Control.Monad +import qualified Data.ByteString as SB +import qualified Data.Text as T +import qualified Data.Text.Encoding as TE import Data.Version import qualified Env import Options.Applicative @@ -57,7 +60,15 @@ combineToInstructions cmd Flags {..} Environment {..} mc = do envDirectoryEnvironment (confDirectoryConfiguration <$> mc) let setColourConfig = getColourSettings (mc >>= confColourConfiguration) - let setGithubOauthToken = flagGithubOAuthToken <|> envGithubOAuthToken <|> cM githubConfOAuthToken + let mTok mToken mTokenFile = case mToken of + Just token -> pure $ Just token + Nothing -> case mTokenFile of + Nothing -> pure Nothing + Just tokenFile -> Just . T.strip . TE.decodeUtf8 <$> SB.readFile tokenFile + flagMTok <- mTok flagGitHubOAuthToken flagGitHubOAuthTokenFile + envMTok <- mTok envGitHubOAuthToken envGitHubOAuthTokenFile + confMTok <- mTok (cM githubConfOAuthToken) (cM githubConfOAuthTokenFile) + let setGitHubOauthToken = flagMTok <|> envMTok <|> confMTok pure (Instructions d Settings {..}) where cM :: (GitHubConfiguration -> Maybe a) -> Maybe a @@ -77,7 +88,8 @@ environmentParser = Report.envWithConfigFileParser $ Environment <$> Report.directoryEnvironmentParser - <*> optional (Env.var Env.str "GITHUB_OAUTH_TOKEN" (Env.help "Github Oauth Token")) + <*> optional (Env.var Env.str "GITHUB_OAUTH_TOKEN" (Env.help "GitHub Oauth Token")) + <*> optional (Env.var Env.str "GITHUB_OAUTH_TOKEN_FILE" (Env.help "GitHub Oauth Token File")) getArguments :: IO Arguments getArguments = do @@ -183,3 +195,12 @@ parseFlags = ] ) ) + <*> optional + ( strOption + ( mconcat + [ long "github-oauth-token-file", + metavar "OAUTH_TOKEN_FILE", + help "A github OAuth token file" + ] + ) + ) diff --git a/smos-github/src/Smos/GitHub/OptParse/Types.hs b/smos-github/src/Smos/GitHub/OptParse/Types.hs index c4f999589..f94afcf79 100644 --- a/smos-github/src/Smos/GitHub/OptParse/Types.hs +++ b/smos-github/src/Smos/GitHub/OptParse/Types.hs @@ -32,7 +32,8 @@ data ImportFlags = ImportFlags data Flags = Flags { flagDirectoryFlags :: !Report.DirectoryFlags, - flagGithubOAuthToken :: !(Maybe Text) + flagGitHubOAuthToken :: !(Maybe Text), + flagGitHubOAuthTokenFile :: !(Maybe FilePath) } deriving (Show, Eq) @@ -52,19 +53,22 @@ instance HasCodec Configuration where <*> optionalFieldOrNull "github" "The github tool configuration" .= confGitHubConfiguration data GitHubConfiguration = GitHubConfiguration - { githubConfOAuthToken :: !(Maybe Text) + { githubConfOAuthToken :: !(Maybe Text), + githubConfOAuthTokenFile :: !(Maybe FilePath) } deriving (Show, Eq) instance HasCodec GitHubConfiguration where codec = - object "GithubConfiguration" $ + object "GitHubConfiguration" $ GitHubConfiguration <$> optionalFieldOrNull "oauth-token" "Oauth token for accessing the github API" .= githubConfOAuthToken + <*> optionalFieldOrNull "oauth-token-file" "Oauth token file for accessing the github API" .= githubConfOAuthTokenFile data Environment = Environment { envDirectoryEnvironment :: !Report.DirectoryEnvironment, - envGithubOAuthToken :: !(Maybe Text) + envGitHubOAuthToken :: !(Maybe Text), + envGitHubOAuthTokenFile :: !(Maybe FilePath) } deriving (Show, Eq) @@ -95,6 +99,6 @@ data ImportDestination = ImportDestination data Settings = Settings { setDirectorySettings :: !Report.DirectoryConfig, setColourConfig :: !ColourSettings, - setGithubOauthToken :: !(Maybe Text) + setGitHubOauthToken :: !(Maybe Text) } deriving (Show, Eq) diff --git a/smos-notify/default.nix b/smos-notify/default.nix new file mode 100644 index 000000000..930f491bf --- /dev/null +++ b/smos-notify/default.nix @@ -0,0 +1,22 @@ +{ mkDerivation, autodocodec, base, conduit, containers, envparse +, hashable, lib, monad-logger, optparse-applicative, path, path-io +, persistent, persistent-sqlite, pretty-relative-time, pretty-show +, process, smos-data, smos-report, text, time +}: +mkDerivation { + pname = "smos-notify"; + version = "0.2.1"; + src = ./.; + isLibrary = true; + isExecutable = true; + enableSeparateDataOutput = true; + libraryHaskellDepends = [ + autodocodec base conduit containers envparse hashable monad-logger + optparse-applicative path path-io persistent persistent-sqlite + pretty-relative-time pretty-show process smos-data smos-report text + time + ]; + executableHaskellDepends = [ base ]; + license = lib.licenses.mit; + mainProgram = "smos-notify"; +} diff --git a/smos-query/default.nix b/smos-query/default.nix new file mode 100644 index 000000000..ba414eeb6 --- /dev/null +++ b/smos-query/default.nix @@ -0,0 +1,36 @@ +{ mkDerivation, aeson, aeson-pretty, autodocodec, autoexporter +, base, bytestring, conduit, containers, envparse, genvalidity +, genvalidity-containers, genvalidity-sydtest +, genvalidity-sydtest-aeson, lib, mtl, optparse-applicative, path +, path-io, pretty-relative-time, safe-coloured-text +, safe-coloured-text-layout, safe-coloured-text-layout-gen +, safe-coloured-text-terminfo, smos-data, smos-report +, smos-report-gen, sydtest, sydtest-discover, text, time, validity +, validity-path, yaml +}: +mkDerivation { + pname = "smos-query"; + version = "0.8.0"; + src = ./.; + isLibrary = true; + isExecutable = true; + libraryHaskellDepends = [ + aeson aeson-pretty autodocodec base bytestring conduit containers + envparse mtl optparse-applicative path pretty-relative-time + safe-coloured-text safe-coloured-text-layout + safe-coloured-text-terminfo smos-data smos-report text time + validity validity-path yaml + ]; + libraryToolDepends = [ autoexporter ]; + executableHaskellDepends = [ base ]; + testHaskellDepends = [ + base containers genvalidity genvalidity-containers + genvalidity-sydtest genvalidity-sydtest-aeson path path-io + safe-coloured-text safe-coloured-text-layout + safe-coloured-text-layout-gen smos-report smos-report-gen sydtest + text yaml + ]; + testToolDepends = [ sydtest-discover ]; + license = lib.licenses.mit; + mainProgram = "smos-query"; +} diff --git a/smos-report-cursor-gen/default.nix b/smos-report-cursor-gen/default.nix new file mode 100644 index 000000000..0746e3bfb --- /dev/null +++ b/smos-report-cursor-gen/default.nix @@ -0,0 +1,29 @@ +{ mkDerivation, base, containers, criterion, cursor, cursor-gen +, genvalidity, genvalidity-containers, genvalidity-criterion +, genvalidity-path, genvalidity-sydtest, genvalidity-sydtest-lens +, lib, microlens, path, QuickCheck, smos-data, smos-data-gen +, smos-report, smos-report-cursor, smos-report-gen, sydtest +, sydtest-discover, time +}: +mkDerivation { + pname = "smos-report-cursor-gen"; + version = "0.2.0"; + src = ./.; + libraryHaskellDepends = [ + base containers cursor cursor-gen genvalidity genvalidity-path + microlens path QuickCheck smos-data smos-data-gen smos-report + smos-report-cursor smos-report-gen + ]; + testHaskellDepends = [ + base genvalidity-sydtest genvalidity-sydtest-lens QuickCheck + smos-data-gen smos-report smos-report-cursor smos-report-gen + sydtest + ]; + testToolDepends = [ sydtest-discover ]; + benchmarkHaskellDepends = [ + base criterion genvalidity genvalidity-containers + genvalidity-criterion genvalidity-path smos-data smos-data-gen + smos-report smos-report-cursor time + ]; + license = lib.licenses.mit; +} diff --git a/smos-report-cursor/default.nix b/smos-report-cursor/default.nix new file mode 100644 index 000000000..c4a2d04f0 --- /dev/null +++ b/smos-report-cursor/default.nix @@ -0,0 +1,14 @@ +{ mkDerivation, base, conduit, containers, cursor, deepseq, lib +, microlens, path, smos-cursor, smos-data, smos-report, time +, validity, validity-path +}: +mkDerivation { + pname = "smos-report-cursor"; + version = "0.3.0"; + src = ./.; + libraryHaskellDepends = [ + base conduit containers cursor deepseq microlens path smos-cursor + smos-data smos-report time validity validity-path + ]; + license = lib.licenses.mit; +} diff --git a/smos-report-gen/default.nix b/smos-report-gen/default.nix new file mode 100644 index 000000000..b647b17c0 --- /dev/null +++ b/smos-report-gen/default.nix @@ -0,0 +1,34 @@ +{ mkDerivation, base, bytestring, containers, criterion, cursor +, cursor-gen, deepseq, dirforest, genvalidity +, genvalidity-bytestring, genvalidity-containers +, genvalidity-criterion, genvalidity-dirforest, genvalidity-path +, genvalidity-sydtest, genvalidity-sydtest-aeson, genvalidity-text +, genvalidity-time, lib, megaparsec, parsec, path, path-io +, QuickCheck, smos-data, smos-data-gen, smos-report, sydtest +, sydtest-discover, text, time +}: +mkDerivation { + pname = "smos-report-gen"; + version = "0.4.3"; + src = ./.; + libraryHaskellDepends = [ + base bytestring containers cursor cursor-gen deepseq dirforest + genvalidity genvalidity-bytestring genvalidity-containers + genvalidity-dirforest genvalidity-path genvalidity-sydtest + genvalidity-text genvalidity-time path path-io QuickCheck smos-data + smos-data-gen smos-report text time + ]; + testHaskellDepends = [ + base containers cursor cursor-gen dirforest genvalidity-containers + genvalidity-path genvalidity-sydtest genvalidity-sydtest-aeson + megaparsec parsec path QuickCheck smos-data smos-data-gen + smos-report sydtest text time + ]; + testToolDepends = [ sydtest-discover ]; + benchmarkHaskellDepends = [ + base containers criterion cursor genvalidity-containers + genvalidity-criterion genvalidity-path path smos-data smos-data-gen + smos-report text + ]; + license = lib.licenses.mit; +} diff --git a/smos-report/default.nix b/smos-report/default.nix new file mode 100644 index 000000000..7117a36ef --- /dev/null +++ b/smos-report/default.nix @@ -0,0 +1,19 @@ +{ mkDerivation, aeson, autodocodec, autodocodec-yaml, base, conduit +, containers, cursor, deepseq, envparse, hashable, lib, megaparsec +, microlens, optparse-applicative, parsec, path, path-io +, pretty-show, safe, smos-data, text, time, validity, validity-path +, validity-time, yaml +}: +mkDerivation { + pname = "smos-report"; + version = "0.9.0"; + src = ./.; + libraryHaskellDepends = [ + aeson autodocodec autodocodec-yaml base conduit containers cursor + deepseq envparse hashable megaparsec microlens optparse-applicative + parsec path path-io pretty-show safe smos-data text time validity + validity-path validity-time yaml + ]; + testHaskellDepends = [ base ]; + license = lib.licenses.mit; +} diff --git a/smos-scheduler/default.nix b/smos-scheduler/default.nix new file mode 100644 index 000000000..cef5dbe39 --- /dev/null +++ b/smos-scheduler/default.nix @@ -0,0 +1,38 @@ +{ mkDerivation, aeson, autodocodec, autodocodec-yaml, autoexporter +, base, bytestring, conduit, containers, cron, dirforest, envparse +, fuzzy-time, genvalidity, genvalidity-containers, genvalidity-path +, genvalidity-sydtest, genvalidity-sydtest-aeson, genvalidity-text +, genvalidity-time, hashable, lib, megaparsec, mtl +, optparse-applicative, path, path-io, pretty-relative-time +, QuickCheck, safe, safe-coloured-text-terminfo, smos-data +, smos-data-gen, smos-query, smos-report, smos-report-gen, sydtest +, sydtest-discover, text, time, unliftio, validity, validity-text +, yaml +}: +mkDerivation { + pname = "smos-scheduler"; + version = "0.6.0"; + src = ./.; + isLibrary = true; + isExecutable = true; + libraryHaskellDepends = [ + aeson autodocodec base bytestring conduit containers cron envparse + fuzzy-time hashable megaparsec mtl optparse-applicative path + path-io pretty-relative-time safe safe-coloured-text-terminfo + smos-data smos-query smos-report text time unliftio validity + validity-text yaml + ]; + libraryToolDepends = [ autoexporter ]; + executableHaskellDepends = [ base ]; + testHaskellDepends = [ + autodocodec autodocodec-yaml base containers cron dirforest + genvalidity genvalidity-containers genvalidity-path + genvalidity-sydtest genvalidity-sydtest-aeson genvalidity-text + genvalidity-time mtl path path-io QuickCheck smos-data + smos-data-gen smos-query smos-report smos-report-gen sydtest text + time + ]; + testToolDepends = [ sydtest-discover ]; + license = lib.licenses.mit; + mainProgram = "smos-scheduler"; +} diff --git a/smos-server-gen/default.nix b/smos-server-gen/default.nix new file mode 100644 index 000000000..672a596cd --- /dev/null +++ b/smos-server-gen/default.nix @@ -0,0 +1,42 @@ +{ mkDerivation, base, bytestring, containers, deepseq, dirforest +, genvalidity, genvalidity-bytestring, genvalidity-persistent +, genvalidity-sydtest, genvalidity-time, genvalidity-typed-uuid +, http-client, http-client-tls, http-types, lib, mergeful, mtl +, path, path-io, persistent, persistent-sqlite, QuickCheck, semver +, servant, servant-auth-client, servant-auth-server, servant-client +, smos-api, smos-api-gen, smos-client, smos-data, smos-data-gen +, smos-report, smos-report-gen, smos-server, smos-sync-client +, sydtest, sydtest-discover, sydtest-persistent-sqlite, sydtest-wai +, text, time, typed-uuid, unliftio, zip, zstd +}: +mkDerivation { + pname = "smos-server-gen"; + version = "0.6.0"; + src = ./.; + isLibrary = true; + isExecutable = true; + libraryHaskellDepends = [ + base bytestring containers deepseq dirforest genvalidity + genvalidity-persistent genvalidity-time genvalidity-typed-uuid + http-client mergeful path persistent-sqlite servant-auth-client + servant-auth-server smos-api-gen smos-client smos-data + smos-data-gen smos-report-gen smos-server smos-sync-client sydtest + sydtest-persistent-sqlite sydtest-wai unliftio + ]; + executableHaskellDepends = [ + base http-client-tls http-types mtl semver servant-client + smos-client smos-data sydtest text + ]; + executableToolDepends = [ sydtest-discover ]; + testHaskellDepends = [ + base bytestring containers dirforest genvalidity-bytestring + genvalidity-persistent genvalidity-sydtest http-types mergeful mtl + path path-io persistent QuickCheck servant servant-client smos-api + smos-client smos-data smos-data-gen smos-report smos-report-gen + smos-server sydtest sydtest-persistent-sqlite time typed-uuid zip + zstd + ]; + testToolDepends = [ sydtest-discover ]; + license = lib.licenses.mit; + mainProgram = "smos-server-end-to-end-test"; +} diff --git a/smos-server/default.nix b/smos-server/default.nix new file mode 100644 index 000000000..5a0a69320 --- /dev/null +++ b/smos-server/default.nix @@ -0,0 +1,31 @@ +{ mkDerivation, aeson, aeson-pretty, autodocodec, autodocodec-yaml +, autoexporter, base, bytestring, conduit, containers, dirforest +, envparse, filepath, http-client, jose, lib, looper, mergeful +, microlens, monad-logger, mtl, optparse-applicative, path, path-io +, persistent, persistent-sqlite, pretty-show, semver, servant +, servant-auth-server, servant-server, smos-api, smos-data +, smos-report, smos-stripe-client, template-haskell, text, time +, typed-uuid, unliftio, validity, validity-persistent, wai +, wai-extra, warp, zip, zstd +}: +mkDerivation { + pname = "smos-server"; + version = "0.10.1"; + src = ./.; + isLibrary = true; + isExecutable = true; + libraryHaskellDepends = [ + aeson aeson-pretty autodocodec autodocodec-yaml base bytestring + conduit containers dirforest envparse filepath http-client jose + looper mergeful microlens monad-logger mtl optparse-applicative + path path-io persistent persistent-sqlite pretty-show semver + servant servant-auth-server servant-server smos-api smos-data + smos-report smos-stripe-client template-haskell text time + typed-uuid unliftio validity validity-persistent wai wai-extra warp + zip zstd + ]; + libraryToolDepends = [ autoexporter ]; + executableHaskellDepends = [ base ]; + license = lib.licenses.mit; + mainProgram = "smos-server"; +} diff --git a/smos-single/default.nix b/smos-single/default.nix new file mode 100644 index 000000000..975624b66 --- /dev/null +++ b/smos-single/default.nix @@ -0,0 +1,18 @@ +{ mkDerivation, autodocodec, base, envparse, lib +, optparse-applicative, path, path-io, smos-data, smos-report, text +, time +}: +mkDerivation { + pname = "smos-single"; + version = "0.2.1"; + src = ./.; + isLibrary = true; + isExecutable = true; + libraryHaskellDepends = [ + autodocodec base envparse optparse-applicative path path-io + smos-data smos-report text time + ]; + executableHaskellDepends = [ base ]; + license = lib.licenses.mit; + mainProgram = "smos-single"; +} diff --git a/smos-sync-client-gen/default.nix b/smos-sync-client-gen/default.nix new file mode 100644 index 000000000..de7a70d77 --- /dev/null +++ b/smos-sync-client-gen/default.nix @@ -0,0 +1,32 @@ +{ mkDerivation, async, base, bytestring, containers, criterion +, dirforest, genvalidity, genvalidity-bytestring +, genvalidity-criterion, genvalidity-dirforest, genvalidity-path +, genvalidity-sydtest, jose, lib, mergeful, monad-logger, path +, path-io, persistent-sqlite, QuickCheck, resource-pool +, servant-auth-server, servant-client, smos-api, smos-api-gen +, smos-server, smos-server-gen, smos-sync-client, sydtest +, sydtest-discover, sydtest-persistent-sqlite, sydtest-wai, text +}: +mkDerivation { + pname = "smos-sync-client-gen"; + version = "0.4.0"; + src = ./.; + libraryHaskellDepends = [ + async base bytestring containers dirforest genvalidity + genvalidity-dirforest genvalidity-sydtest monad-logger path path-io + persistent-sqlite QuickCheck servant-client smos-api smos-api-gen + smos-sync-client sydtest sydtest-persistent-sqlite + ]; + testHaskellDepends = [ + base bytestring containers genvalidity-bytestring genvalidity-path + genvalidity-sydtest jose mergeful monad-logger path path-io + persistent-sqlite QuickCheck resource-pool servant-auth-server + servant-client smos-api smos-api-gen smos-server smos-server-gen + smos-sync-client sydtest sydtest-persistent-sqlite sydtest-wai text + ]; + testToolDepends = [ sydtest-discover ]; + benchmarkHaskellDepends = [ + base criterion genvalidity-criterion smos-sync-client + ]; + license = lib.licenses.mit; +} diff --git a/smos-sync-client/default.nix b/smos-sync-client/default.nix new file mode 100644 index 000000000..30af26cc8 --- /dev/null +++ b/smos-sync-client/default.nix @@ -0,0 +1,30 @@ +{ mkDerivation, aeson, aeson-pretty, autodocodec, autoexporter +, base, bytestring, containers, cookie, deepseq, dirforest +, envparse, filelock, filepath, hostname, http-client +, http-client-tls, http-types, lib, mergeful, monad-logger, mtl +, optparse-applicative, path, path-io, persistent +, persistent-sqlite, pretty-show, servant-auth-client +, servant-client, smos-api, smos-client, smos-data, smos-report +, text, time, unix, unliftio, validity, validity-bytestring +, validity-containers, validity-path, validity-uuid +}: +mkDerivation { + pname = "smos-sync-client"; + version = "0.4.3"; + src = ./.; + isLibrary = true; + isExecutable = true; + libraryHaskellDepends = [ + aeson aeson-pretty autodocodec base bytestring containers cookie + deepseq dirforest envparse filelock filepath hostname http-client + http-client-tls http-types mergeful monad-logger mtl + optparse-applicative path path-io persistent persistent-sqlite + pretty-show servant-auth-client servant-client smos-api smos-client + smos-data smos-report text time unix unliftio validity + validity-bytestring validity-containers validity-path validity-uuid + ]; + libraryToolDepends = [ autoexporter ]; + executableHaskellDepends = [ base ]; + license = lib.licenses.mit; + mainProgram = "smos-sync-client"; +} diff --git a/smos-sync-client/src/Smos/Sync/Client/OptParse.hs b/smos-sync-client/src/Smos/Sync/Client/OptParse.hs index 601f95ef6..395283de5 100644 --- a/smos-sync-client/src/Smos/Sync/Client/OptParse.hs +++ b/smos-sync-client/src/Smos/Sync/Client/OptParse.hs @@ -9,9 +9,12 @@ module Smos.Sync.Client.OptParse where import Control.Arrow (left) +import Control.Monad.IO.Class import Control.Monad.Logger +import qualified Data.ByteString as SB import Data.Maybe import qualified Data.Text as T +import qualified Data.Text.Encoding as TE import Data.Version import qualified Env import Options.Applicative @@ -56,20 +59,27 @@ combineToInstructions c Flags {..} Environment {..} mc = do let setLogLevel = fromMaybe LevelWarn $ flagLogLevel <|> envLogLevel <|> cM syncConfLogLevel let setUsername = flagUsername <|> envUsername <|> cM syncConfUsername setPassword <- runStderrLoggingT $ - filterLogger (\_ ll -> ll >= setLogLevel) $ + filterLogger (\_ ll -> ll >= setLogLevel) $ do + let readPasswordFrom pf = mkPassword . T.strip . TE.decodeUtf8 <$> liftIO (SB.readFile pf) case flagPassword of Just p -> do logWarnN "Plaintext password in flags may end up in shell history." pure (Just p) - Nothing -> - case envPassword of - Just p -> pure (Just p) - Nothing -> - case cM syncConfPassword of - Just p -> do - logWarnN "Plaintext password in config file." - pure (Just p) - Nothing -> pure Nothing + Nothing -> case flagPasswordFile of + Just pf -> Just <$> readPasswordFrom pf + Nothing -> + case envPassword of + Just p -> pure (Just p) + Nothing -> case envPasswordFile of + Just pf -> Just <$> readPasswordFrom pf + Nothing -> + case cM syncConfPassword of + Just p -> do + logWarnN "Plaintext password in config file." + pure (Just p) + Nothing -> case cM syncConfPasswordFile of + Just pf -> Just <$> readPasswordFrom pf + Nothing -> pure Nothing setSessionPath <- case flagSessionPath <|> envSessionPath <|> cM syncConfSessionPath of Nothing -> resolveFile cacheDir "sync-session.dat" @@ -143,6 +153,7 @@ environmentParser = <*> optional (Env.var emptyDirsReader "EMPTY_DIRS" (Env.help "What to do with empty directories after syncing")) <*> optional (Env.var usernameReader "USERNAME" (Env.help "The username to sync with")) <*> optional (Env.var (fmap mkPassword . Env.str) "PASSWORD" (Env.help "The password to sync with")) + <*> optional (Env.var Env.str "PASSWORD_FILE" (Env.help "The password file to sync with")) <*> optional (Env.var Env.str "SESSION_PATH" (Env.help "The path to the file in which to store the auth session")) <*> optional (Env.var Env.str "BACKUP_DIR" (Env.help "The directory to store backups in when a sync conflict happens")) where @@ -336,6 +347,14 @@ parseFlags = ] ) ) + <*> optional + ( strOption + ( mconcat + [ long "password-file", + help "The password file to login to the sync server" + ] + ) + ) <*> optional ( strOption ( mconcat diff --git a/smos-sync-client/src/Smos/Sync/Client/OptParse/Types.hs b/smos-sync-client/src/Smos/Sync/Client/OptParse/Types.hs index 5593f3884..d8bccd1ee 100644 --- a/smos-sync-client/src/Smos/Sync/Client/OptParse/Types.hs +++ b/smos-sync-client/src/Smos/Sync/Client/OptParse/Types.hs @@ -51,6 +51,7 @@ data Flags = Flags flagServerUrl :: !(Maybe String), flagUsername :: !(Maybe Username), flagPassword :: !(Maybe Password), + flagPasswordFile :: !(Maybe FilePath), flagDataDir :: !(Maybe FilePath), flagCacheDir :: !(Maybe FilePath), flagSessionPath :: !(Maybe FilePath) @@ -68,6 +69,7 @@ data Environment = Environment envEmptyDirs :: !(Maybe EmptyDirs), envUsername :: !(Maybe Username), envPassword :: !(Maybe Password), + envPasswordFile :: !(Maybe FilePath), envSessionPath :: !(Maybe FilePath), envBackupDir :: !(Maybe FilePath) } @@ -98,6 +100,7 @@ data SyncConfiguration = SyncConfiguration syncConfEmptyDirs :: !(Maybe EmptyDirs), syncConfUsername :: !(Maybe Username), syncConfPassword :: !(Maybe Password), + syncConfPasswordFile :: !(Maybe FilePath), syncConfSessionPath :: !(Maybe FilePath), syncConfBackupDir :: !(Maybe FilePath) } @@ -152,6 +155,10 @@ instance HasCodec SyncConfiguration where "password" "The password to log into the sync server. Note that putting the password in a config file in plaintext is not safe. Only use this for automation." .= syncConfPassword + <*> optionalFieldOrNull + "password-file" + "The password file to log into the sync server." + .= syncConfPasswordFile <*> optionalFieldOrNull "session-path" "The file in which to store the login session cookie" diff --git a/smos-web-server/default.nix b/smos-web-server/default.nix new file mode 100644 index 000000000..f49ab7fe8 --- /dev/null +++ b/smos-web-server/default.nix @@ -0,0 +1,42 @@ +{ mkDerivation, aeson, autodocodec, autodocodec-yaml, autoexporter +, base, base16-bytestring, bytestring, conduit, containers +, data-default, deepseq, envparse, genvalidity-sydtest, http-client +, http-client-tls, http-types, lib, monad-logger, mtl +, optparse-applicative, path, path-io, persistent-sqlite +, pretty-relative-time, pretty-show, QuickCheck, servant +, servant-auth-client, servant-client, shakespeare, smos +, smos-client, smos-data-gen, smos-server-gen, smos-sync-client +, smos-web-style, stm, sydtest, sydtest-discover, sydtest-yesod +, template-haskell, text, time, typed-uuid, unliftio, wai-extra +, warp, yesod, yesod-auth, yesod-autoreload, yesod-static +, yesod-static-remote, yesod-websockets +}: +mkDerivation { + pname = "smos-web-server"; + version = "0.9.0"; + src = ./.; + isLibrary = true; + isExecutable = true; + libraryHaskellDepends = [ + aeson autodocodec autodocodec-yaml base base16-bytestring + bytestring conduit containers data-default deepseq envparse + http-client http-client-tls http-types monad-logger mtl + optparse-applicative path path-io persistent-sqlite + pretty-relative-time pretty-show servant servant-auth-client + servant-client shakespeare smos smos-client smos-sync-client + smos-web-style stm template-haskell text time typed-uuid unliftio + wai-extra warp yesod yesod-auth yesod-autoreload yesod-static + yesod-static-remote yesod-websockets + ]; + libraryToolDepends = [ autoexporter ]; + executableHaskellDepends = [ base ]; + testHaskellDepends = [ + base containers genvalidity-sydtest http-client http-types + monad-logger QuickCheck servant-client smos-client smos-data-gen + smos-server-gen smos-web-style stm sydtest sydtest-yesod text + yesod-auth + ]; + testToolDepends = [ sydtest-discover ]; + license = lib.licenses.mit; + mainProgram = "smos-web-server"; +} diff --git a/smos-web-style/default.nix b/smos-web-style/default.nix new file mode 100644 index 000000000..8f9ff6da7 --- /dev/null +++ b/smos-web-style/default.nix @@ -0,0 +1,13 @@ +{ mkDerivation, autoexporter, base, lib, path, path-io, process +, template-haskell, yesod-static +}: +mkDerivation { + pname = "smos-web-style"; + version = "0.0.2"; + src = ./.; + libraryHaskellDepends = [ + base path path-io process template-haskell yesod-static + ]; + libraryToolDepends = [ autoexporter ]; + license = lib.licenses.mit; +} diff --git a/smos/default.nix b/smos/default.nix new file mode 100644 index 000000000..f4b269f9b --- /dev/null +++ b/smos/default.nix @@ -0,0 +1,46 @@ +{ mkDerivation, aeson, async, autodocodec, base, brick, bytestring +, conduit, containers, cursor, cursor-brick, cursor-dirforest +, cursor-dirforest-brick, cursor-fuzzy-time, directory, dirforest +, envparse, exceptions, filelock, filepath, fuzzy-time, genvalidity +, genvalidity-containers, genvalidity-path, genvalidity-sydtest +, genvalidity-sydtest-aeson, genvalidity-sydtest-lens +, genvalidity-text, genvalidity-time +, genvalidity-unordered-containers, lib, megaparsec, microlens +, monad-logger, mtl, optparse-applicative, path, path-io +, pretty-relative-time, pretty-show, process, QuickCheck, resourcet +, safe, smos-archive, smos-cursor, smos-cursor-gen, smos-data +, smos-data-gen, smos-report, smos-report-cursor, smos-report-gen +, sydtest, sydtest-discover, text, time, unix, unliftio, validity +, validity-containers, validity-text, validity-time +, validity-unordered-containers, vty, yaml +}: +mkDerivation { + pname = "smos"; + version = "0.6.1"; + src = ./.; + isLibrary = true; + isExecutable = true; + libraryHaskellDepends = [ + aeson async autodocodec base brick bytestring conduit containers + cursor cursor-brick cursor-dirforest cursor-dirforest-brick + cursor-fuzzy-time directory envparse exceptions filepath fuzzy-time + megaparsec microlens monad-logger mtl optparse-applicative path + path-io pretty-relative-time pretty-show process resourcet safe + smos-archive smos-cursor smos-data smos-report smos-report-cursor + text time unix unliftio validity validity-containers validity-text + validity-time validity-unordered-containers vty + ]; + executableHaskellDepends = [ base ]; + testHaskellDepends = [ + aeson async base bytestring conduit containers dirforest filelock + genvalidity genvalidity-containers genvalidity-path + genvalidity-sydtest genvalidity-sydtest-aeson + genvalidity-sydtest-lens genvalidity-text genvalidity-time + genvalidity-unordered-containers megaparsec mtl path path-io + QuickCheck resourcet smos-cursor-gen smos-data smos-data-gen + smos-report-gen sydtest text time unliftio vty yaml + ]; + testToolDepends = [ sydtest-discover ]; + license = lib.licenses.mit; + mainProgram = "smos"; +} diff --git a/statix.toml b/statix.toml index 4f1254537..a003122b6 100644 --- a/statix.toml +++ b/statix.toml @@ -1,5 +1,6 @@ disabled = [ "eta_reduction", "manual_inherit_from", + "unquoted_uri", ]