# SPDX-FileCopyrightText: 2022-2023 Gregor Kleen ,Sarah Vaupel # # SPDX-License-Identifier: AGPL-3.0-or-later rec { inputs = { # haskell-nix = { # url = "github:input-output-hk/haskell.nix"; # }; nixpkgs = { type = "github"; owner = "NixOS"; repo = "nixpkgs"; ref = "master"; }; docker-nixpkgs = { url = "github:nix-community/docker-nixpkgs"; flake = false; }; flake-utils = { type = "github"; owner = "numtide"; repo = "flake-utils"; ref = "main"; }; }; outputs = { self, nixpkgs, docker-nixpkgs, flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system: let frontendSource = pkgs.lib.sourceByRegex ./. [ "^(assets|frontend)(/.*)?$" "^config(/(favicon\.json|robots\.txt))?$" "^(webpack|postcss)\.config\.js$" "^karma\.conf\.js$" "^(package|jsconfig|\.eslintrc)\.json$" "^\.babelrc$" ]; backendSource = pkgs.lib.sourceByRegex ./. [ "^(\.hlint|package|stack-flake)\.yaml$" "^stack\.yaml\.lock$" "^config(/(archive-types|mimetypes|personalised-sheet-files-collate|settings\.yml|submission-blacklist|test-settings\.yml|video-types|wordlist\.txt))?$" "^routes$" "^testdata(/.*)?$" ]; pkgs = import nixpkgs { inherit system overlays; config.allowUnfree = true; }; overlays = [ (import "${docker-nixpkgs}/overlay.nix") (import ./nix/maildev) # haskell-nix.overlay (import ./nix/uniworx { inherit inputs frontendSource backendSource; }) (import ./nix/docker { inherit self; }) (import ./nix/parse-changelog.nix {}) ]; haskellFlake = pkgs.uniworx.flake {}; mkPushDocker = imageName: dockerImage: pkgs.writeScriptBin "push-${dockerImage.imageName}" '' #!${pkgs.zsh}/bin/zsh -xe target=''${1-docker://registry.gitlab.com/fradrive/fradrive/${imageName}:${dockerImage.imageTag}} [[ -n "''${1}" ]] && shift ${pkgs.skopeo}/bin/skopeo ''${@} --insecure-policy copy docker-archive://${dockerImage} ''${target} ''; inherit (pkgs.lib) recursiveUpdate; in { packages = haskellFlake.packages // { inherit (pkgs) uniworxNodeDependencies uniworxWellKnown uniworxFrontend uniworxDemoDocker uniworxDocker ciDocker changelogJson; }; apps = haskellFlake.apps // { pushUniworxDemoDocker = flake-utils.lib.mkApp { drv = mkPushDocker "uniworx-demo" pkgs.uniworxDemoDocker; }; pushUniworxDocker = flake-utils.lib.mkApp { drv = mkPushDocker "uniworx" pkgs.uniworxDocker; }; pushCIDocker = flake-utils.lib.mkApp { drv = mkPushDocker "nix-unstable" pkgs.ciDocker; }; calculateMaterializedSha = flake-utils.lib.mkApp { drv = pkgs.uniworx.stack-nix.passthru.calculateMaterializedSha; execPath = ""; }; jqChangelogJson = flake-utils.lib.mkApp { drv = pkgs.jqChangelogJson; }; }; checks = haskellFlake.checks // { uniworxFrontend = pkgs.uniworxFrontend.check; }; devShell = import ./shell.nix { pkgs = self.legacyPackages.${system}; nixpkgsPath = nixpkgs; }; legacyPackages = pkgs.lib.foldr (overlay: acc: acc // recursiveUpdate (overlay self.legacyPackages.${system} pkgs) pkgs) {} overlays; defaultPackage = self.packages.${system}."uniworx:exe:uniworx"; defaultApp = self.apps.${system}."uniworx:exe:uniworx"; } ); }