From 33a1d10ef40af90289b73ce9491784f806cd9c17 Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Mon, 6 Mar 2023 20:03:01 +0100 Subject: [PATCH] Revert "Revert "fix(build): revert nix flake config to obtain container"" This reverts commit 1d8188023f15fa0437dcd3727db0d5d186f8cbc4. --- flake.lock | 563 ++++++++++++++++++++++++++++++++++++++++++++++++++++- flake.nix | 151 ++++++++++++-- shell.nix | 235 ++-------------------- 3 files changed, 706 insertions(+), 243 deletions(-) diff --git a/flake.lock b/flake.lock index f5c74561b..dedb5ba85 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,206 @@ { "nodes": { + "HTTP": { + "flake": false, + "locked": { + "lastModified": 1451647621, + "narHash": "sha256-oHIyw3x0iKBexEo49YeUDV1k74ZtyYKGR2gNJXXRxts=", + "owner": "phadej", + "repo": "HTTP", + "rev": "9bc0996d412fef1787449d841277ef663ad9a915", + "type": "github" + }, + "original": { + "owner": "phadej", + "repo": "HTTP", + "type": "github" + } + }, + "HaskellNet-SSL": { + "flake": false, + "locked": { + "lastModified": 1582382981, + "narHash": "sha256-fjw+bKaGrGw9uTUd6fWZCIz24uuSTA1VIeijZ+zSq/M=", + "ref": "uni2work", + "rev": "40393c938111ac78232dc2c7eec5edb4a22d03e8", + "revCount": 62, + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/HaskellNet-SSL.git" + }, + "original": { + "ref": "uni2work", + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/HaskellNet-SSL.git" + } + }, + "cabal-32": { + "flake": false, + "locked": { + "lastModified": 1603716527, + "narHash": "sha256-sDbrmur9Zfp4mPKohCD8IDZfXJ0Tjxpmr2R+kg5PpSY=", + "owner": "haskell", + "repo": "cabal", + "rev": "94aaa8e4720081f9c75497e2735b90f6a819b08e", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "3.2", + "repo": "cabal", + "type": "github" + } + }, + "cabal-34": { + "flake": false, + "locked": { + "lastModified": 1622475795, + "narHash": "sha256-chwTL304Cav+7p38d9mcb+egABWmxo2Aq+xgVBgEb/U=", + "owner": "haskell", + "repo": "cabal", + "rev": "b086c1995cdd616fc8d91f46a21e905cc50a1049", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "3.4", + "repo": "cabal", + "type": "github" + } + }, + "cardano-shell": { + "flake": false, + "locked": { + "lastModified": 1608537748, + "narHash": "sha256-PulY1GfiMgKVnBci3ex4ptk2UNYMXqGjJOxcPy2KYT4=", + "owner": "input-output-hk", + "repo": "cardano-shell", + "rev": "9392c75087cb9a3d453998f4230930dea3a95725", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "cardano-shell", + "type": "github" + } + }, + "colonnade": { + "flake": false, + "locked": { + "lastModified": 1592144408, + "narHash": "sha256-bQSOjbn56ZEjzqkC/oqZ331FdxF7tbhJndtXeRqWcq8=", + "ref": "uni2work", + "rev": "f8170266ab25b533576e96715bedffc5aa4f19fa", + "revCount": 153, + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/colonnade.git" + }, + "original": { + "ref": "uni2work", + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/colonnade.git" + } + }, + "conduit-resumablesink": { + "flake": false, + "locked": { + "lastModified": 1533667275, + "narHash": "sha256-+TR0tYRk1WFQRrFs6oO80jdlfY7OTyB7th7Hi/tDQMw=", + "ref": "uni2work", + "rev": "cbea6159c2975d42f948525e03e12fc390da53c5", + "revCount": 10, + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/conduit-resumablesink.git" + }, + "original": { + "ref": "uni2work", + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/conduit-resumablesink.git" + } + }, + "cryptoids": { + "flake": false, + "locked": { + "lastModified": 1602592869, + "narHash": "sha256-uhbIaVFXtdWmeDJl0ZDyJnE2Ul3bV324KkaK+ix6USA=", + "ref": "uni2work", + "rev": "130b0dcbf2b09ccdf387b50262f1efbbbf1819e3", + "revCount": 44, + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/cryptoids.git" + }, + "original": { + "ref": "uni2work", + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/cryptoids.git" + } + }, + "cryptonite": { + "flake": false, + "locked": { + "lastModified": 1624444174, + "narHash": "sha256-sDMA4ej1NIModAt7PQvcgIknI3KwfzcAp9YQUSe4CWw=", + "ref": "uni2work", + "rev": "71a630edaf5f22c464e24fac8d9d310f4055ea1f", + "revCount": 1202, + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/cryptonite.git" + }, + "original": { + "ref": "uni2work", + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/cryptonite.git" + } + }, + "docker-nixpkgs": { + "flake": false, + "locked": { + "lastModified": 1631525111, + "narHash": "sha256-dJKw280B1Hp0f6tSkBtkY0nrMT0DR/bmerrS3cQdBjI=", + "owner": "nix-community", + "repo": "docker-nixpkgs", + "rev": "df7f64139a0b2384fb2448dc2a406815f8d03867", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "docker-nixpkgs", + "type": "github" + } + }, + "encoding": { + "flake": false, + "locked": { + "lastModified": 1582400874, + "narHash": "sha256-ukQw4tvjtvqR8HEPgPTSmvtTc6WeXEs3IfCLLNy+YJc=", + "ref": "uni2work", + "rev": "22fc3bb14841d8d50997aa47f1be3852e666f787", + "revCount": 162, + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/encoding.git" + }, + "original": { + "ref": "uni2work", + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/encoding.git" + } + }, + "esqueleto": { + "flake": false, + "locked": { + "lastModified": 1648739688, + "narHash": "sha256-rtKhMti9GNq0i7ngTLuNXIyr3zSUTh3G8anXPrKirTk=", + "ref": "uni2work", + "rev": "e18dd125c5ea26fa4e88bed079b61d8c1365ee37", + "revCount": 708, + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/esqueleto.git" + }, + "original": { + "ref": "uni2work", + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/esqueleto.git" + } + }, "flake-utils": { "locked": { "lastModified": 1623875721, @@ -11,31 +212,379 @@ }, "original": { "owner": "numtide", - "ref": "master", "repo": "flake-utils", "type": "github" } }, + "fontawesome-token": { + "flake": false, + "locked": { + "narHash": "sha256-XABvCxD/7zXRyyR01dr5IvK+8A0VoibiVUS5ZAU+f+o=", + "path": "/etc/fontawesome-token", + "type": "path" + }, + "original": { + "path": "/etc/fontawesome-token", + "type": "path" + } + }, + "ghc-8.6.5-iohk": { + "flake": false, + "locked": { + "lastModified": 1600920045, + "narHash": "sha256-DO6kxJz248djebZLpSzTGD6s8WRpNI9BTwUeOf5RwY8=", + "owner": "input-output-hk", + "repo": "ghc", + "rev": "95713a6ecce4551240da7c96b6176f980af75cae", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "ref": "release/8.6.5-iohk", + "repo": "ghc", + "type": "github" + } + }, + "hackage": { + "flake": false, + "locked": { + "lastModified": 1629940355, + "narHash": "sha256-o9/U8R/JtyHIcxhMLaWYP+D/52B6LH/ikCyNZ7+mymI=", + "owner": "input-output-hk", + "repo": "hackage.nix", + "rev": "429deb2a137084c011310bad92f4cecf244f2fc2", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "hackage.nix", + "type": "github" + } + }, + "haskell-nix": { + "inputs": { + "HTTP": "HTTP", + "cabal-32": "cabal-32", + "cabal-34": "cabal-34", + "cardano-shell": "cardano-shell", + "flake-utils": "flake-utils", + "ghc-8.6.5-iohk": "ghc-8.6.5-iohk", + "hackage": "hackage", + "hpc-coveralls": "hpc-coveralls", + "nix-tools": "nix-tools", + "nixpkgs": "nixpkgs", + "nixpkgs-2003": "nixpkgs-2003", + "nixpkgs-2009": "nixpkgs-2009", + "nixpkgs-2105": "nixpkgs-2105", + "nixpkgs-unstable": "nixpkgs-unstable", + "old-ghc-nix": "old-ghc-nix", + "stackage": "stackage" + }, + "locked": { + "lastModified": 1629940530, + "narHash": "sha256-cf/bshYWloj+rJSmOcFokN6Rs1lpFkiECKpykN3JBH8=", + "owner": "input-output-hk", + "repo": "haskell.nix", + "rev": "5fcd4faf98fc8ca8287e2c7bc1fff71dfd340f1f", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "haskell.nix", + "type": "github" + } + }, + "hpc-coveralls": { + "flake": false, + "locked": { + "lastModified": 1607498076, + "narHash": "sha256-8uqsEtivphgZWYeUo5RDUhp6bO9j2vaaProQxHBltQk=", + "owner": "sevanspowell", + "repo": "hpc-coveralls", + "rev": "14df0f7d229f4cd2e79f8eabb1a740097fdfa430", + "type": "github" + }, + "original": { + "owner": "sevanspowell", + "repo": "hpc-coveralls", + "type": "github" + } + }, + "ldap-client": { + "flake": false, + "locked": { + "lastModified": 1582401733, + "narHash": "sha256-StLj8BnQqbl8fnE+xWlSOScVRGnl19cv8d1CBZ29O0k=", + "ref": "uni2work", + "rev": "01afaf599ba6f8a9d804c269e91d3190b249d3f0", + "revCount": 61, + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/ldap-client.git" + }, + "original": { + "ref": "uni2work", + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/ldap-client.git" + } + }, + "memcached-binary": { + "flake": false, + "locked": { + "lastModified": 1582403725, + "narHash": "sha256-40BNhNNYC/B4u16dKwBrkk5hmhncq805YC4y1aGFRqs=", + "ref": "uni2work", + "rev": "b7071df50bad3a251a544b984e4bf98fa09b8fae", + "revCount": 28, + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/memcached-binary.git" + }, + "original": { + "ref": "uni2work", + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/memcached-binary.git" + } + }, + "minio-hs": { + "flake": false, + "locked": { + "lastModified": 1597069863, + "narHash": "sha256-JmMajaLT4+zt+w2koDkaloFL8ugmrQBlcYKj+78qn9M=", + "ref": "uni2work", + "rev": "42103ab247057c04c8ce7a83d9d4c160713a3df1", + "revCount": 197, + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/minio-hs.git" + }, + "original": { + "ref": "uni2work", + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/minio-hs.git" + } + }, + "nix-tools": { + "flake": false, + "locked": { + "lastModified": 1626997434, + "narHash": "sha256-1judQmP298ao6cGUNxcGhcAXHOnA9qSLvWk/ZtoUL7w=", + "owner": "input-output-hk", + "repo": "nix-tools", + "rev": "c8c5e6a6fbb12a73598d1a434984a36e880ce3cf", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "nix-tools", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1624788075, - "narHash": "sha256-xzO2aL5gGejNvey2jKGnbnFXbo99pdytlY5FF/IhvAE=", + "lastModified": 1624291665, + "narHash": "sha256-kNkaoa3dai9WOi7fsPklCCWZ8hRAkXx0ZUhpYKShyUk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "4ba70da807359ed01d662763a96c7b442762e5ef", + "rev": "3c6f3f84af60a8ed5b8a79cf3026b7630fcdefb8", "type": "github" }, "original": { "owner": "NixOS", - "ref": "master", + "ref": "nixpkgs-20.09-darwin", "repo": "nixpkgs", "type": "github" } }, + "nixpkgs-2003": { + "locked": { + "lastModified": 1620055814, + "narHash": "sha256-8LEHoYSJiL901bTMVatq+rf8y7QtWuZhwwpKE2fyaRY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1db42b7fe3878f3f5f7a4f2dc210772fd080e205", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-20.03-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2009": { + "locked": { + "lastModified": 1624271064, + "narHash": "sha256-qns/uRW7MR2EfVf6VEeLgCsCp7pIOjDeR44JzTF09MA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "46d1c3f28ca991601a53e9a14fdd53fcd3dd8416", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-20.09-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2105": { + "locked": { + "lastModified": 1624291665, + "narHash": "sha256-kNkaoa3dai9WOi7fsPklCCWZ8hRAkXx0ZUhpYKShyUk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3c6f3f84af60a8ed5b8a79cf3026b7630fcdefb8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-21.05-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1628785280, + "narHash": "sha256-2B5eMrEr6O8ff2aQNeVxTB+9WrGE80OB4+oM6T7fOcc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6525bbc06a39f26750ad8ee0d40000ddfdc24acb", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "old-ghc-nix": { + "flake": false, + "locked": { + "lastModified": 1621819714, + "narHash": "sha256-EJCnYQSWk7FRLwS0lZgTWIiQ6pcvDX1VuD6LGD4Uwzs=", + "owner": "angerman", + "repo": "old-ghc-nix", + "rev": "f089a6f090cdb35fcf95f865fc6a31ba6b3ac4eb", + "type": "github" + }, + "original": { + "owner": "angerman", + "ref": "master2", + "repo": "old-ghc-nix", + "type": "github" + } + }, "root": { "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "HaskellNet-SSL": "HaskellNet-SSL", + "colonnade": "colonnade", + "conduit-resumablesink": "conduit-resumablesink", + "cryptoids": "cryptoids", + "cryptonite": "cryptonite", + "docker-nixpkgs": "docker-nixpkgs", + "encoding": "encoding", + "esqueleto": "esqueleto", + "flake-utils": [ + "haskell-nix", + "flake-utils" + ], + "fontawesome-token": "fontawesome-token", + "haskell-nix": "haskell-nix", + "ldap-client": "ldap-client", + "memcached-binary": "memcached-binary", + "minio-hs": "minio-hs", + "nixpkgs": [ + "haskell-nix", + "nixpkgs-unstable" + ], + "serversession": "serversession", + "xss-sanitize": "xss-sanitize", + "yesod": "yesod", + "zip-stream": "zip-stream" + } + }, + "serversession": { + "flake": false, + "locked": { + "lastModified": 1624794082, + "narHash": "sha256-mixhAsgOq0iiAhOcZfFSyl8CwS7utaKeZBz/Lix16hk=", + "ref": "uni2work", + "rev": "b9d76def10da1260c7f6aa82bda32111f37a952b", + "revCount": 174, + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/serversession.git" + }, + "original": { + "ref": "uni2work", + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/serversession.git" + } + }, + "stackage": { + "flake": false, + "locked": { + "lastModified": 1629940472, + "narHash": "sha256-LFrNC25OpNoS6dGG5om+UGP8YdYjp01Qm6cenbemaVg=", + "owner": "input-output-hk", + "repo": "stackage.nix", + "rev": "c50dd0527babf85818cc67a7099e532e453752db", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "stackage.nix", + "type": "github" + } + }, + "xss-sanitize": { + "flake": false, + "locked": { + "lastModified": 1602593438, + "narHash": "sha256-2jAHm79x8f+ygGHq9gipF3h8+eMT7eCxVMOGMc/brKE=", + "ref": "uni2work", + "rev": "dc928c3a456074b8777603bea20e81937321777f", + "revCount": 114, + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/xss-sanitize.git" + }, + "original": { + "ref": "uni2work", + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/xss-sanitize.git" + } + }, + "yesod": { + "flake": false, + "locked": { + "lastModified": 1625061191, + "narHash": "sha256-K0X2MwUStChml1DlJ7t4yBMDwrMe6j/780nJtSy9Hss=", + "ref": "uni2work", + "rev": "a59f63e0336ee61f7a90b8778e9147305d3127bb", + "revCount": 5053, + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/yesod.git" + }, + "original": { + "ref": "uni2work", + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/yesod.git" + } + }, + "zip-stream": { + "flake": false, + "locked": { + "lastModified": 1599734754, + "narHash": "sha256-gqIlgj2dxVkqEMafuVL+dqZPoV+WLpOJwz1NhsKnH64=", + "ref": "uni2work", + "rev": "843683d024f767de236f74d24a3348f69181a720", + "revCount": 39, + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/zip-stream.git" + }, + "original": { + "ref": "uni2work", + "type": "git", + "url": "https://gitlab.ifi.lmu.de/uni2work/haskell/zip-stream.git" } } }, diff --git a/flake.nix b/flake.nix index 8f1d9f7e2..e8c0da651 100644 --- a/flake.nix +++ b/flake.nix @@ -1,36 +1,145 @@ -# SPDX-FileCopyrightText: 2022 Gregor Kleen +# SPDX-FileCopyrightText: 2022 Gregor Kleen ,Steffen Jost # # SPDX-License-Identifier: AGPL-3.0-or-later { - inputs = { - nixpkgs = { - type = "github"; - owner = "NixOS"; - repo = "nixpkgs"; - ref = "master"; - }; - flake-utils = { - type = "github"; - owner = "numtide"; - repo = "flake-utils"; - ref = "master"; - }; + inputs.haskell-nix.url = "github:input-output-hk/haskell.nix"; + inputs.nixpkgs.follows = "haskell-nix/nixpkgs-unstable"; + inputs.flake-utils.follows = "haskell-nix/flake-utils"; + + inputs.docker-nixpkgs = { + url = "github:nix-community/docker-nixpkgs"; + flake = false; }; - outputs = { self, nixpkgs, flake-utils, ... }: flake-utils.lib.eachDefaultSystem + inputs.encoding = { + url = "git+https://gitlab.ifi.lmu.de/uni2work/haskell/encoding.git?ref=uni2work"; + flake = false; + }; + inputs.memcached-binary = { + url = "git+https://gitlab.ifi.lmu.de/uni2work/haskell/memcached-binary.git?ref=uni2work"; + flake = false; + }; + inputs.conduit-resumablesink = { + url = "git+https://gitlab.ifi.lmu.de/uni2work/haskell/conduit-resumablesink.git?ref=uni2work"; + flake = false; + }; + inputs.HaskellNet-SSL = { + url = "git+https://gitlab.ifi.lmu.de/uni2work/haskell/HaskellNet-SSL.git?ref=uni2work"; + flake = false; + }; + inputs.ldap-client = { + url = "git+https://gitlab.ifi.lmu.de/uni2work/haskell/ldap-client.git?ref=uni2work"; + flake = false; + }; + inputs.serversession = { + url = "git+https://gitlab.ifi.lmu.de/uni2work/haskell/serversession.git?ref=uni2work"; + flake = false; + }; + inputs.xss-sanitize = { + url = "git+https://gitlab.ifi.lmu.de/uni2work/haskell/xss-sanitize.git?ref=uni2work"; + flake = false; + }; + inputs.colonnade = { + url = "git+https://gitlab.ifi.lmu.de/uni2work/haskell/colonnade.git?ref=uni2work"; + flake = false; + }; + inputs.minio-hs = { + url = "git+https://gitlab.ifi.lmu.de/uni2work/haskell/minio-hs.git?ref=uni2work"; + flake = false; + }; + inputs.cryptoids = { + url = "git+https://gitlab.ifi.lmu.de/uni2work/haskell/cryptoids.git?ref=uni2work"; + flake = false; + }; + inputs.zip-stream = { + url = "git+https://gitlab.ifi.lmu.de/uni2work/haskell/zip-stream.git?ref=uni2work"; + flake = false; + }; + inputs.yesod = { + url = "git+https://gitlab.ifi.lmu.de/uni2work/haskell/yesod.git?ref=uni2work"; + flake = false; + }; + inputs.cryptonite = { + url = "git+https://gitlab.ifi.lmu.de/uni2work/haskell/cryptonite.git?ref=uni2work"; + flake = false; + }; + inputs.esqueleto = { + url = "git+https://gitlab.ifi.lmu.de/uni2work/haskell/esqueleto.git?ref=uni2work"; + flake = false; + }; + + inputs.fontawesome-token = { + url = "path:/etc/fontawesome-token"; + flake = false; + }; + + outputs = inputs@{ self, nixpkgs, flake-utils, haskell-nix, docker-nixpkgs, ... }: flake-utils.lib.eachSystem ["x86_64-linux"] (system: - let pkgs = import nixpkgs { - inherit 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$" + "^(assets|app|hlint|load|messages|models|src|templates|test|testdata)(/.*)?$" + "^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; }; - overlay = import ./nix/maildev; + overlays = [ + # remove once https://github.com/NixOS/nix/pull/5266 has landed in nixpkgs used here (see flake.lock) + (import ./nix/aws-patch.nix) + # end remove - inherit (pkgs.lib) recursiveUpdate; + (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} + ''; in { - devShell = import ./shell.nix { pkgs = self.legacyPackages.${system}; nixpkgsPath = nixpkgs; }; + 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; exePath = ""; }; + jqChangelogJson = flake-utils.lib.mkApp { drv = pkgs.jqChangelogJson; }; + }; + checks = haskellFlake.checks // { + uniworxFrontend = pkgs.uniworxFrontend.check; + }; + + devShell = import ./shell.nix { inherit pkgs; }; - legacyPackages = recursiveUpdate (overlay self.legacyPackages.${system} pkgs) pkgs; + legacyPackages = pkgs; + + defaultPackage = self.packages.${system}."uniworx:exe:uniworx"; + defaultApp = self.apps.${system}."uniworx:exe:uniworx"; } ); } diff --git a/shell.nix b/shell.nix index af1ccb11a..d381dcecb 100644 --- a/shell.nix +++ b/shell.nix @@ -1,217 +1,27 @@ -# SPDX-FileCopyrightText: 2022 Gregor Kleen ,Sarah Vaupel +# SPDX-FileCopyrightText: 2022 Gregor Kleen ,Sarah Vaupel ,Steffen Jost # # SPDX-License-Identifier: AGPL-3.0-or-later -{ pkgs ? (import ./nixpkgs.nix {}).pkgs, nixpkgsPath ? null }: +{ pkgs ? (import ./nixpkgs.nix {}).pkgs }: let inherit (pkgs.lib) optionalString; haskellPackages = pkgs.haskellPackages; - postgresSchema = pkgs.writeText "schema.sql" '' - CREATE USER uniworx WITH SUPERUSER; - CREATE DATABASE uniworx_test; - GRANT ALL ON DATABASE uniworx_test TO uniworx; - CREATE DATABASE uniworx; - GRANT ALL ON DATABASE uniworx TO uniworx; - ''; - - postgresHba = pkgs.writeText "hba_file" '' - local all all trust - ''; - - develop = pkgs.writeScriptBin "develop" '' - #!${pkgs.zsh}/bin/zsh -e - - basePath=$(pwd) - exec 4<>''${basePath}/.develop.env - - flockRes= - set +e - ${pkgs.util-linux}/bin/flock -en 4; flockRes=$? - set -e - if [[ ''${flockRes} -ne 0 ]]; then - echo "Could not take exclusive lock; is another develop running?" >&2 - exit ''${flockRes} - fi - - cleanup() { - set +e -x - type cleanup_postgres &>/dev/null && cleanup_postgres - type cleanup_widget_memcached &>/dev/null && cleanup_widget_memcached - type cleanup_session_memcached &>/dev/null && cleanup_session_memcached - type cleanup_cache_memcached &>/dev/null && cleanup_cache_memcached - type cleanup_minio &>/dev/null && cleanup_minio - type cleanup_maildev &>/dev/null && cleanup_maildev - - [ -f "''${basePath}/.develop.env" ] && rm -vf "''${basePath}/.develop.env" - set +x - } - - trap cleanup EXIT - - export PORT_OFFSET=$(((16#$(sha256sum <<<"$(hostname -f):''${basePath}" | head -c 16)) % 1000)) - - if [[ -z "$PGHOST" ]]; then - set -xe - - pgDir=$(mktemp -d --tmpdir=''${XDG_RUNTIME_DIR} postgresql.XXXXXX) - pgSockDir=$(mktemp -d --tmpdir=''${XDG_RUNTIME_DIR} postgresql.sock.XXXXXX) - pgLogFile=$(mktemp --tmpdir=''${XDG_RUNTIME_DIR} postgresql.XXXXXX.log) - initdb --no-locale -D ''${pgDir} - pg_ctl start -D ''${pgDir} -l ''${pgLogFile} -w -o "-k ''${pgSockDir} -c listen_addresses=''' -c hba_file='${postgresHba}' -c unix_socket_permissions=0700 -c max_connections=9990 -c shared_preload_libraries=pg_stat_statements -c session_preload_libraries=auto_explain -c auto_explain.log_min_duration=100ms" - psql -h ''${pgSockDir} -f ${postgresSchema} postgres - printf "Postgres logfile is %s\nPostgres socket directory is %s\n" ''${pgLogFile} ''${pgSockDir} - - export PGHOST=''${pgSockDir} - export PGLOG=''${pgLogFile} - - cleanup_postgres() { - set +e -x - pg_ctl stop -D ''${pgDir} - rm -rvf ''${pgDir} ''${pgSockDir} ''${pgLogFile} - set +x - } - - set +xe - fi - - if [[ -z "$WIDGET_MEMCACHED_HOST" ]]; then - set -xe - - memcached -l localhost -p $(($PORT_OFFSET + 11211)) &>/dev/null & - widget_memcached_pid=$! - - export WIDGET_MEMCACHED_HOST=localhost - export WIDGET_MEMCACHED_PORT=$(($PORT_OFFSET + 11211)) - - cleanup_widget_memcached() { - [[ -n "$widget_memcached_pid" ]] && kill $widget_memcached_pid - } - - set +xe - fi - - if [[ -z "$SESSION_MEMCACHED_HOST" ]]; then - set -xe - - memcached -l localhost -p $(($PORT_OFFSET + 11212)) &>/dev/null & - session_memcached_pid=$! - - export SESSION_MEMCACHED_HOST=localhost - export SESSION_MEMCACHED_PORT=$(($PORT_OFFSET + 11212)) - - cleanup_session_memcached() { - [[ -n "$session_memcached_pid" ]] && kill $session_memcached_pid - } - - set +xe - fi - - if [[ -z "$MEMCACHED_HOST" ]]; then - set -xe - - memcached -l localhost -p $(($PORT_OFFSET + 11213)) &>/dev/null & - memcached_pid=$! - - export MEMCACHED_HOST=localhost - export MEMCACHED_PORT=$(($PORT_OFFSET + 11212)) - - cleanup_session_memcached() { - [[ -n "$memcached_pid" ]] && kill $memcached_pid - } - - set +xe - fi - - if [[ -z "$UPLOAD_S3_HOST" ]]; then - set -xe - - cleanup_minio() { - [[ -n "$minio_pid" ]] && kill $minio_pid - [[ -n "''${MINIO_DIR}" ]] && rm -rvf ''${MINIO_DIR} - [[ -n "''${MINIO_LOGFILE}" ]] && rm -rvf ''${MINIO_LOGFILE} - } - - export MINIO_DIR=$(mktemp -d --tmpdir=''${XDG_RUNTIME_DIR} minio.XXXXXX) - export MINIO_LOGFILE=$(mktemp --tmpdir=''${XDG_RUNTIME_DIR} minio.XXXXXX.log) - export MINIO_ACCESS_KEY=$(${pkgs.pwgen}/bin/pwgen -s 16 1) - export MINIO_SECRET_KEY=$(${pkgs.pwgen}/bin/pwgen -s 32 1) - - minio server --address localhost:$(($PORT_OFFSET + 9000)) ''${MINIO_DIR} &>''${MINIO_LOGFILE} & - minio_pid=$! - - export UPLOAD_S3_HOST=localhost - export UPLOAD_S3_PORT=$(($PORT_OFFSET + 9000)) - export UPLOAD_S3_SSL=false - export UPLOAD_S3_KEY_ID=''${MINIO_ACCESS_KEY} - export UPLOAD_S3_KEY=''${MINIO_SECRET_KEY} - - sleep 1 - - set +xe - fi - - ${optionalString (pkgs.nodePackages ? "maildev") '' - if [[ -z "$SMTPHOST" ]]; then - set -xe - - cleanup_maildev() { - [[ -n "$maildev_pid" ]] && kill $maildev_pid - } - - TMPDIR=''${XDG_RUNTIME_DIR} ${pkgs.nodePackages.maildev}/bin/maildev --smtp $(($PORT_OFFSET + 1025)) --web $(($PORT_OFFSET + 8080)) --ip localhost --web-ip localhost &>/dev/null & - maildev_pid=$! - - export SMTPHOST=localhost - export SMTPPORT=$(($PORT_OFFSET + 1025)) - export SMTPSSL=none - - set +xe + develop = pkgs.writeScriptBin "develop" (import ./nix/develop.nix { inherit pkgs; } '' + if [ -x .develop.cmd ]; then + ./.develop.cmd + else + if [ -n "$ZSH_VERSION" ]; then + autoload -U +X compinit && compinit + autoload -U +X bashcompinit && bashcompinit fi - ''} + eval "$(stack --bash-completion-script stack)" - set -xe - - cat >&4 <