A music player that connects to your cloud/distributed storage.
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

Nix flakes (#343)

authored by

Steven Vandevelde and committed by
GitHub
cd676607 525c345e

+253 -285
+1 -1
.envrc
··· 1 - eval "$(lorri direnv)" 1 + use flake
+1
.gitignore
··· 8 8 *.zip 9 9 elm-stuff 10 10 /.deploy* 11 + /.direnv 11 12 /.stack-work 12 13 /build 13 14 /diffuse
+2 -1
Justfile
··· 169 169 # 170 170 171 171 @dev: build 172 - just watch-wo-build & just server 172 + # just watch-wo-build & just server 173 + just server 173 174 174 175 175 176 @doc-tests:
+1 -1
README.md
··· 60 60 61 61 ### Building it yourself 62 62 63 - This project uses [Nix](https://nixos.org/features.html) to manage the project's environment. If you'd like to build this project without Nix, check out the dependencies in the `shell.nix` file (most are available through Homebrew as well). 63 + This project uses [Nix](https://nixos.org/features.html) to manage the project's environment. If you'd like to build this project without Nix, check out the dependencies in the `nix/shell.nix` file (most are available through Homebrew as well). 64 64 65 65 66 66 ```shell
+94
flake.lock
··· 1 + { 2 + "nodes": { 3 + "flake-utils": { 4 + "locked": { 5 + "lastModified": 1656928814, 6 + "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=", 7 + "owner": "numtide", 8 + "repo": "flake-utils", 9 + "rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249", 10 + "type": "github" 11 + }, 12 + "original": { 13 + "owner": "numtide", 14 + "repo": "flake-utils", 15 + "type": "github" 16 + } 17 + }, 18 + "flake-utils_2": { 19 + "locked": { 20 + "lastModified": 1656065134, 21 + "narHash": "sha256-oc6E6ByIw3oJaIyc67maaFcnjYOz1mMcOtHxbEf9NwQ=", 22 + "owner": "numtide", 23 + "repo": "flake-utils", 24 + "rev": "bee6a7250dd1b01844a2de7e02e4df7d8a0a206c", 25 + "type": "github" 26 + }, 27 + "original": { 28 + "owner": "numtide", 29 + "repo": "flake-utils", 30 + "type": "github" 31 + } 32 + }, 33 + "nixpkgs": { 34 + "locked": { 35 + "lastModified": 1658380158, 36 + "narHash": "sha256-DBunkegKWlxPZiOcw3/SNIFg93amkdGIy2g0y/jDpHg=", 37 + "owner": "NixOS", 38 + "repo": "nixpkgs", 39 + "rev": "a65b5b3f5504b8b89c196aba733bdf2b0bd13c16", 40 + "type": "github" 41 + }, 42 + "original": { 43 + "owner": "NixOS", 44 + "ref": "nixos-unstable", 45 + "repo": "nixpkgs", 46 + "type": "github" 47 + } 48 + }, 49 + "nixpkgs_2": { 50 + "locked": { 51 + "lastModified": 1656401090, 52 + "narHash": "sha256-bUS2nfQsvTQW2z8SK7oEFSElbmoBahOPtbXPm0AL3I4=", 53 + "owner": "NixOS", 54 + "repo": "nixpkgs", 55 + "rev": "16de63fcc54e88b9a106a603038dd5dd2feb21eb", 56 + "type": "github" 57 + }, 58 + "original": { 59 + "owner": "NixOS", 60 + "ref": "nixpkgs-unstable", 61 + "repo": "nixpkgs", 62 + "type": "github" 63 + } 64 + }, 65 + "root": { 66 + "inputs": { 67 + "flake-utils": "flake-utils", 68 + "nixpkgs": "nixpkgs", 69 + "rust-overlay": "rust-overlay" 70 + } 71 + }, 72 + "rust-overlay": { 73 + "inputs": { 74 + "flake-utils": "flake-utils_2", 75 + "nixpkgs": "nixpkgs_2" 76 + }, 77 + "locked": { 78 + "lastModified": 1658544517, 79 + "narHash": "sha256-ipu69vA0a6AcWZqnHLzeRhvnVZbURXALHLIsqQWtJe4=", 80 + "owner": "oxalica", 81 + "repo": "rust-overlay", 82 + "rev": "4bd340885e39e0625fc6dda8a5a9d13c921ebb96", 83 + "type": "github" 84 + }, 85 + "original": { 86 + "owner": "oxalica", 87 + "repo": "rust-overlay", 88 + "type": "github" 89 + } 90 + } 91 + }, 92 + "root": "root", 93 + "version": 7 94 + }
+25
flake.nix
··· 1 + { 2 + description = "diffuse"; 3 + 4 + 5 + # Inputs 6 + # ====== 7 + 8 + inputs = { 9 + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; 10 + flake-utils.url = "github:numtide/flake-utils"; 11 + rust-overlay.url = "github:oxalica/rust-overlay"; 12 + }; 13 + 14 + 15 + # Outputs 16 + # ======= 17 + 18 + outputs = { self, nixpkgs, flake-utils, rust-overlay }: 19 + flake-utils.lib.simpleFlake { 20 + inherit self nixpkgs; 21 + name = "diffuse"; 22 + shell = ./nix/shell.nix; 23 + preOverlays = [ (import rust-overlay) ]; 24 + }; 25 + }
+98
nix/shell.nix
··· 1 + { pkgs ? import <nixpkgs> {} }: with pkgs; let 2 + 3 + # Rust 4 + # ---- 5 + 6 + rust = rust-bin.stable.latest.default; 7 + rustPlatform = makeRustPlatform { 8 + cargo = rust; 9 + rustc = rust; 10 + }; 11 + 12 + # Trying to fix an issue with `watchexec` on MacOS 13 + # https://github.com/h4llow3En/mac-notification-sys/issues/28 14 + # Nix uses old Apple SDKs? Not sure, but definitely a Nix issue. 15 + watchexec = rustPlatform.buildRustPackage rec { 16 + pname = "watchexec"; 17 + version = "1.20.4"; 18 + 19 + cargoSha256 = "sha256-YM+Zm3wFp3Lsx5LmyjGwZywV/SZjriL6JMDO1l0tNf4="; 20 + 21 + src = fetchFromGitHub { 22 + owner = pname; 23 + repo = pname; 24 + rev = "cli-v${version}"; 25 + sha256 = "sha256-se3iqz+qjwf71wvHQhCWYryEdUc+kY0Q0ZTg4i1ayNI="; 26 + }; 27 + 28 + nativeBuildInputs = lib.optionals 29 + stdenv.isDarwin 30 + (with darwin.apple_sdk_11_0.frameworks; [ Cocoa Foundation ]); 31 + }; 32 + 33 + # Wraps 34 + # ----- 35 + # Inspired by https://www.tweag.io/blog/2022-06-02-haskell-stack-nix-shell/ 36 + 37 + stack-wrapped = symlinkJoin { 38 + name = "stack"; 39 + paths = [ stack ]; 40 + buildInputs = [ makeWrapper ]; 41 + postBuild = '' 42 + wrapProgram $out/bin/stack \ 43 + --add-flags "\ 44 + --nix \ 45 + --no-nix-pure \ 46 + --nix-shell-file=nix/stack-integration.nix \ 47 + " 48 + ''; 49 + }; 50 + 51 + # Dependencies 52 + # ------------ 53 + 54 + deps = { 55 + 56 + tools = [ 57 + curl 58 + just 59 + simple-http-server 60 + # watchexec 61 + ]; 62 + 63 + languages = [ 64 + elmPackages.elm 65 + elmPackages.elm-format 66 + nodejs-18_x 67 + nodePackages.pnpm 68 + rust 69 + stack-wrapped 70 + ]; 71 + 72 + tauri = { 73 + # Needed to build Tauri on Mac OS 74 + # https://github.com/NixOS/nixpkgs/blob/master/pkgs/os-specific/darwin/apple-sdk/frameworks.nix 75 + macOS = [ 76 + darwin.apple_sdk.frameworks.AppKit 77 + darwin.apple_sdk.frameworks.WebKit 78 + libiconv 79 + ]; 80 + }; 81 + 82 + }; 83 + 84 + in 85 + 86 + mkShell { 87 + 88 + buildInputs = builtins.concatLists [ 89 + deps.tools 90 + deps.languages 91 + 92 + # Mac OS dependencies 93 + (lib.optionals stdenv.isDarwin deps.tauri.macOS) 94 + ]; 95 + 96 + NIX_PATH = "nixpkgs=" + path; 97 + 98 + }
-38
nix/sources.json
··· 1 - { 2 - "niv": { 3 - "branch": "master", 4 - "description": "Easy dependency management for Nix projects", 5 - "homepage": "https://github.com/nmattia/niv", 6 - "owner": "nmattia", 7 - "repo": "niv", 8 - "rev": "82e5cd1ad3c387863f0545d7591512e76ab0fc41", 9 - "sha256": "090l219mzc0gi33i3psgph6s2pwsc8qy4lyrqjdj4qzkvmaj65a7", 10 - "type": "tarball", 11 - "url": "https://github.com/nmattia/niv/archive/82e5cd1ad3c387863f0545d7591512e76ab0fc41.tar.gz", 12 - "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" 13 - }, 14 - "nixpkgs": { 15 - "branch": "nixpkgs-unstable", 16 - "description": "Nix Packages collection", 17 - "homepage": null, 18 - "owner": "NixOS", 19 - "repo": "nixpkgs", 20 - "rev": "17b62c338f2a0862a58bb6951556beecd98ccda9", 21 - "sha256": "1yzbc85m9vbhsfprljzjkkskh9sxchid9m28wkgwsckqnf47r911", 22 - "type": "tarball", 23 - "url": "https://github.com/NixOS/nixpkgs/archive/17b62c338f2a0862a58bb6951556beecd98ccda9.tar.gz", 24 - "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" 25 - }, 26 - "old-packages": { 27 - "branch": "nixos-21.05", 28 - "description": "Nix Packages collection", 29 - "homepage": "", 30 - "owner": "NixOS", 31 - "repo": "nixpkgs", 32 - "rev": "530a53dcbc9437363471167a5e4762c5fcfa34a1", 33 - "sha256": "11d9m0c4r4kpr3jx3cqblw6ld4d8dwcfv1lk68ipp4c87knwv7fb", 34 - "type": "tarball", 35 - "url": "https://github.com/NixOS/nixpkgs/archive/530a53dcbc9437363471167a5e4762c5fcfa34a1.tar.gz", 36 - "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" 37 - } 38 - }
-174
nix/sources.nix
··· 1 - # This file has been generated by Niv. 2 - 3 - let 4 - 5 - # 6 - # The fetchers. fetch_<type> fetches specs of type <type>. 7 - # 8 - 9 - fetch_file = pkgs: name: spec: 10 - let 11 - name' = sanitizeName name + "-src"; 12 - in 13 - if spec.builtin or true then 14 - builtins_fetchurl { inherit (spec) url sha256; name = name'; } 15 - else 16 - pkgs.fetchurl { inherit (spec) url sha256; name = name'; }; 17 - 18 - fetch_tarball = pkgs: name: spec: 19 - let 20 - name' = sanitizeName name + "-src"; 21 - in 22 - if spec.builtin or true then 23 - builtins_fetchTarball { name = name'; inherit (spec) url sha256; } 24 - else 25 - pkgs.fetchzip { name = name'; inherit (spec) url sha256; }; 26 - 27 - fetch_git = name: spec: 28 - let 29 - ref = 30 - if spec ? ref then spec.ref else 31 - if spec ? branch then "refs/heads/${spec.branch}" else 32 - if spec ? tag then "refs/tags/${spec.tag}" else 33 - abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!"; 34 - in 35 - builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; }; 36 - 37 - fetch_local = spec: spec.path; 38 - 39 - fetch_builtin-tarball = name: throw 40 - ''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`. 41 - $ niv modify ${name} -a type=tarball -a builtin=true''; 42 - 43 - fetch_builtin-url = name: throw 44 - ''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`. 45 - $ niv modify ${name} -a type=file -a builtin=true''; 46 - 47 - # 48 - # Various helpers 49 - # 50 - 51 - # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695 52 - sanitizeName = name: 53 - ( 54 - concatMapStrings (s: if builtins.isList s then "-" else s) 55 - ( 56 - builtins.split "[^[:alnum:]+._?=-]+" 57 - ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name) 58 - ) 59 - ); 60 - 61 - # The set of packages used when specs are fetched using non-builtins. 62 - mkPkgs = sources: system: 63 - let 64 - sourcesNixpkgs = 65 - import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; }; 66 - hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; 67 - hasThisAsNixpkgsPath = <nixpkgs> == ./.; 68 - in 69 - if builtins.hasAttr "nixpkgs" sources 70 - then sourcesNixpkgs 71 - else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then 72 - import <nixpkgs> {} 73 - else 74 - abort 75 - '' 76 - Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or 77 - add a package called "nixpkgs" to your sources.json. 78 - ''; 79 - 80 - # The actual fetching function. 81 - fetch = pkgs: name: spec: 82 - 83 - if ! builtins.hasAttr "type" spec then 84 - abort "ERROR: niv spec ${name} does not have a 'type' attribute" 85 - else if spec.type == "file" then fetch_file pkgs name spec 86 - else if spec.type == "tarball" then fetch_tarball pkgs name spec 87 - else if spec.type == "git" then fetch_git name spec 88 - else if spec.type == "local" then fetch_local spec 89 - else if spec.type == "builtin-tarball" then fetch_builtin-tarball name 90 - else if spec.type == "builtin-url" then fetch_builtin-url name 91 - else 92 - abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; 93 - 94 - # If the environment variable NIV_OVERRIDE_${name} is set, then use 95 - # the path directly as opposed to the fetched source. 96 - replace = name: drv: 97 - let 98 - saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name; 99 - ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}"; 100 - in 101 - if ersatz == "" then drv else 102 - # this turns the string into an actual Nix path (for both absolute and 103 - # relative paths) 104 - if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}"; 105 - 106 - # Ports of functions for older nix versions 107 - 108 - # a Nix version of mapAttrs if the built-in doesn't exist 109 - mapAttrs = builtins.mapAttrs or ( 110 - f: set: with builtins; 111 - listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)) 112 - ); 113 - 114 - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 115 - range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1); 116 - 117 - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 118 - stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); 119 - 120 - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269 121 - stringAsChars = f: s: concatStrings (map f (stringToCharacters s)); 122 - concatMapStrings = f: list: concatStrings (map f list); 123 - concatStrings = builtins.concatStringsSep ""; 124 - 125 - # https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331 126 - optionalAttrs = cond: as: if cond then as else {}; 127 - 128 - # fetchTarball version that is compatible between all the versions of Nix 129 - builtins_fetchTarball = { url, name ? null, sha256 }@attrs: 130 - let 131 - inherit (builtins) lessThan nixVersion fetchTarball; 132 - in 133 - if lessThan nixVersion "1.12" then 134 - fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) 135 - else 136 - fetchTarball attrs; 137 - 138 - # fetchurl version that is compatible between all the versions of Nix 139 - builtins_fetchurl = { url, name ? null, sha256 }@attrs: 140 - let 141 - inherit (builtins) lessThan nixVersion fetchurl; 142 - in 143 - if lessThan nixVersion "1.12" then 144 - fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) 145 - else 146 - fetchurl attrs; 147 - 148 - # Create the final "sources" from the config 149 - mkSources = config: 150 - mapAttrs ( 151 - name: spec: 152 - if builtins.hasAttr "outPath" spec 153 - then abort 154 - "The values in sources.json should not have an 'outPath' attribute" 155 - else 156 - spec // { outPath = replace name (fetch config.pkgs name spec); } 157 - ) config.sources; 158 - 159 - # The "config" used by the fetchers 160 - mkConfig = 161 - { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null 162 - , sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile) 163 - , system ? builtins.currentSystem 164 - , pkgs ? mkPkgs sources system 165 - }: rec { 166 - # The sources, i.e. the attribute set of spec name to spec 167 - inherit sources; 168 - 169 - # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers 170 - inherit pkgs; 171 - }; 172 - 173 - in 174 - mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }
+23
nix/stack-integration.nix
··· 1 + { ghc }: 2 + with (import <nixpkgs> {}); 3 + let 4 + macos = 5 + if stdenv.isDarwin then 6 + [ 7 + darwin.apple_sdk.frameworks.CoreServices 8 + darwin.apple_sdk.frameworks.Foundation 9 + darwin.apple_sdk.frameworks.Cocoa 10 + ] 11 + else 12 + []; 13 + in 14 + haskell.lib.buildStackProject { 15 + inherit ghc; 16 + name = "diffuse"; 17 + buildInputs = [ 18 + lzma 19 + openssl 20 + postgresql 21 + zlib 22 + ] ++ macos; 23 + }
+2 -2
package.yaml
··· 10 10 dependencies: 11 11 - aeson 12 12 - base >= 4.7 && < 5 13 - - bytestring == 0.10.* 13 + - bytestring == 0.* 14 14 - cmark == 0.6.* 15 - - flow == 1.* 15 + - flow == 2.* 16 16 - protolude 17 17 - shikensu 18 18 - text == 1.*
+3 -61
shell.nix
··· 1 - let 2 - 3 - sources = import ./nix/sources.nix; 4 - pkgs = import sources.nixpkgs { overlays = [ (import rustOverlay) ]; }; 5 - 6 - rustOverlay = builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"; 7 - 8 - # Dependencies 9 - # ------------ 10 - 11 - deps = { 12 - 13 - tools = [ 14 - pkgs.curl 15 - pkgs.just 16 - pkgs.simple-http-server 17 - pkgs.watchexec 18 - ]; 19 - 20 - languages = [ 21 - pkgs.elmPackages.elm 22 - pkgs.elmPackages.elm-format 23 - pkgs.haskellPackages.stack 24 - pkgs.nodejs-18_x 25 - pkgs.nodePackages.pnpm 26 - 27 - pkgs.rust-bin.stable.latest.default 28 - # (pkgs.rust-bin.stable.latest.default.override { 29 - # targets = 30 - # if pkgs.stdenv.isDarwin then 31 - # [ "aarch64-apple-darwin" "x86_64-apple-darwin" ] 32 - # else 33 - # []; 34 - # }) 35 - ]; 36 - 37 - tauri = { 38 - # Needed to build Tauri on Mac OS 39 - # https://github.com/NixOS/nixpkgs/blob/master/pkgs/os-specific/darwin/apple-sdk/frameworks.nix 40 - macOS = [ 41 - pkgs.darwin.apple_sdk.frameworks.AppKit 42 - pkgs.darwin.apple_sdk.frameworks.WebKit 43 - pkgs.libiconv 44 - ]; 45 - }; 46 - 47 - }; 48 - 49 - in 50 - 51 - pkgs.mkShell { 52 - 53 - buildInputs = builtins.concatLists [ 54 - deps.tools 55 - deps.languages 56 - 57 - # Mac OS dependencies 58 - (pkgs.lib.optionals pkgs.stdenv.isDarwin deps.tauri.macOS) 59 - ]; 60 - 61 - } 1 + (import (fetchTarball { 2 + url = "https://github.com/edolstra/flake-compat/archive/b4a34015c698c7793d592d66adbab377907a2be8.tar.gz"; 3 + }) { src = ./.; }).shellNix
+3 -7
stack.yaml
··· 1 - resolver: nightly-2021-12-26 1 + resolver: lts-19.16 2 2 recommend-stack-upgrade: false 3 - 4 - # nix: 5 - # enable: true 3 + allow-newer: true 6 4 7 5 extra-deps: 8 - - aeson-2.0.2.0 9 - - protolude-0.2.4 10 - - shikensu-0.4.0 6 + - protolude-0.3.2