diff --git a/default.nix b/default.nix index 0b12780..54773b8 100644 --- a/default.nix +++ b/default.nix @@ -4,7 +4,37 @@ in { imports = [ "${sources.home-manager}/nixos" ./modules ]; boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; + # boot.loader.efi.canTouchEfiVariables = true; + + boot.loader = { + efi = { + canTouchEfiVariables = true; + # assuming /boot is the mount point of the EFI partition in NixOS (as the installation section recommends). + efiSysMountPoint = "/boot"; + }; + grub = { + # despite what the configuration.nix manpage seems to indicate, + # as of release 17.09, setting device to "nodev" will still call + # `grub-install` if efiSupport is true + # (the devices list is not used by the EFI grub install, + # but must be set to some value in order to pass an assert in grub.nix) + devices = [ "nodev" ]; + efiSupport = true; + enable = true; + # set $FS_UUID to the UUID of the EFI partition + extraEntries = '' + menuentry "Windows" { + insmod part_gpt + insmod fat + insmod search_fs_uuid + insmod chain + search --fs-uuid --set=root $FS_UUID + chainloader /EFI/Microsoft/Boot/bootmgfw.efi + } + ''; + version = 2; + }; + }; # Enable the OpenSSH daemon. services.openssh.enable = true; @@ -12,7 +42,10 @@ in { # Enable sound. sound.enable = true; - # home-manager.users.adrielus.home.packages = with pkgs; [ bluez bluez-tools ]; + home-manager.users.adrielus = { + manual.manpages.enable = false; + # home.packages = with pkgs; [ bluez bluez-tools ]; + }; # Enable blueman # services.blueman.enable = true; @@ -57,6 +90,8 @@ in { # Service.ExecStart = "${pkgs.bluez}/bin/mpris-proxy"; # Install.WantedBy = [ "default.target" ]; # }; + system.stateVersion = "20.03"; + } diff --git a/modules/applications/default.nix b/modules/applications/default.nix index 2f988ae..6f4b4da 100644 --- a/modules/applications/default.nix +++ b/modules/applications/default.nix @@ -4,16 +4,17 @@ ./shells # ./wakatime ./xmonad + ./xmodmap # ./wine.nix ./steam.nix - # ./docker.nix + ./docker.nix ./misc.nix ./locale.nix # ./memes.nix ./alacritty.nix ./rofi.nix - # ./postgres.nix + ./postgres.nix ]; } diff --git a/modules/applications/docker.nix b/modules/applications/docker.nix index 487eb15..fe9bfa7 100644 --- a/modules/applications/docker.nix +++ b/modules/applications/docker.nix @@ -1,7 +1,14 @@ { pkgs, ... }: { - virtualisation.docker.enable = true; + virtualisation.docker = { + enable = true; + liveRestore = false; + extraOptions = '' + --default-address-pool "base=192.168.100.0/20,size=24" + ''; + }; home-manager.users.adrielus.home.packages = with pkgs; [ docker docker-compose + docker-machine ]; } diff --git a/modules/applications/git/default.nix b/modules/applications/git/default.nix index 44c322b..16d59a1 100644 --- a/modules/applications/git/default.nix +++ b/modules/applications/git/default.nix @@ -15,6 +15,7 @@ userName = "Matei Adriel"; userEmail = "rafaeladriel11@gmail.com"; + extraConfig.core.editor = "nvim"; aliases = import ./aliases.nix; diff --git a/modules/applications/misc.nix b/modules/applications/misc.nix index 6b67161..cb8a02b 100644 --- a/modules/applications/misc.nix +++ b/modules/applications/misc.nix @@ -5,22 +5,29 @@ exa # ls replacement mkpasswd # hash passwords gnupg - typespeed # speed typing game - unixtools.xxd # to dump binary stuff into a text file (used it for a ctf) + # typespeed # speed typing game + # unixtools.xxd # to dump binary stuff into a text file (used it for a ctf) # youtube-dl # download from youtube neofetch # display system information xclip # copy paste stuff - feh # image viewer + # feh # image viewer unzip # for working with .zip files speedtest-cli # test the internet speed and stuff # openssl # pkgconfig # ngrok - hugo + # hugo unrar # jdk11o # jdk8 # gtk3 + gnumake + # unison-ucm + xorg.libX11 + texlive.combined.scheme-full + okular + zathura + cmake # editors # vscodium @@ -52,7 +59,7 @@ libreoffice # free office suite # edopro # yugioh simulator (my derivation doesn't work yet) # akonadi - # obs-studio # video recorder + obs-studio # video recorder # blueman # bluetooth manager # freesweep # minesweeper I can play w the keyboard. # multimc diff --git a/modules/applications/xmodmap/.Xmodmap b/modules/applications/xmodmap/.Xmodmap new file mode 100644 index 0000000..0ab19eb --- /dev/null +++ b/modules/applications/xmodmap/.Xmodmap @@ -0,0 +1,5 @@ +! Remap caps lock to control +clear lock +clear control +add control = Caps_Lock Control_L Control_R +keycode 66 = Control_L Caps_Lock NoSymbol NoSymbol \ No newline at end of file diff --git a/modules/applications/xmodmap/default.nix b/modules/applications/xmodmap/default.nix new file mode 100644 index 0000000..9f9a7b0 --- /dev/null +++ b/modules/applications/xmodmap/default.nix @@ -0,0 +1,8 @@ +{ pkgs, ... }: { + home-manager.users.adrielus.home = { + packages = [ pkgs.xorg.xmodmap ]; + file.".Xmodmap".source = ./.Xmodmap; + }; + services.xserver.displayManager.sessionCommands = + "${pkgs.xorg.xmodmap}/bin/xmodmap .Xmodmap"; +} diff --git a/modules/dev/default.nix b/modules/dev/default.nix index ccb7afe..f1d102e 100644 --- a/modules/dev/default.nix +++ b/modules/dev/default.nix @@ -6,8 +6,9 @@ ./javascript.nix ./fsharp.nix ./rust.nix - ./racket.nix - ./elm.nix + ./idris.nix + # ./racket.nix + # ./elm.nix ./dhall.nix ./haskell ]; diff --git a/modules/dev/fsharp.nix b/modules/dev/fsharp.nix index 58aa114..7f47d43 100644 --- a/modules/dev/fsharp.nix +++ b/modules/dev/fsharp.nix @@ -1,3 +1,7 @@ { pkgs, ... }: { - home-manager.users.adrielus.home.packages = with pkgs; [ dotnet-sdk mono ]; + home-manager.users.adrielus.home.packages = with pkgs; [ + dotnet-sdk + mono + packet + ]; } diff --git a/modules/dev/haskell/default.nix b/modules/dev/haskell/default.nix index a795e24..b3d60e3 100644 --- a/modules/dev/haskell/default.nix +++ b/modules/dev/haskell/default.nix @@ -1,11 +1,11 @@ { pkgs, ... }: -let hie = pkgs.all-hies.selection { selector = p: { inherit (p) ghc865; }; }; -in { +# let hie = pkgs.all-hies.selection { selector = p: { inherit (p) ghc865; }; }; +{ home-manager.users.adrielus.home = { file.".ghci".source = ./ghci; packages = with pkgs; [ ghc ghcid hlint cabal-install snack stack ] - ++ (with haskellPackages; [ brittany hoogle hpack pointfree ]); + ++ (with haskellPackages; [ brittany hoogle hpack ]); }; } diff --git a/modules/dev/haskell/ghci b/modules/dev/haskell/ghci index 5dfbb66..4ea943a 100644 --- a/modules/dev/haskell/ghci +++ b/modules/dev/haskell/ghci @@ -5,6 +5,6 @@ :def hoogle-all \str -> return $ ":! hoogle search --color " ++ show str :def doc \str -> return $ ":! hoogle search --color --info " ++ show str -:def pointfree \str -> return $ ":! pointfree " ++ show str -:def pf \str -> return $ ":! pointfree " ++ show str +-- :def pointfree \str -> return $ ":! pointfree " ++ show str +-- :def pf \str -> return $ ":! pointfree " ++ show str -- :def pointful \str -> return $ ":! pointful " ++ show str \ No newline at end of file diff --git a/modules/dev/idris.nix b/modules/dev/idris.nix new file mode 100644 index 0000000..47798cd --- /dev/null +++ b/modules/dev/idris.nix @@ -0,0 +1,3 @@ +{ pkgs, ... }: { + home-manager.users.adrielus.home.packages = with pkgs; [ idris2 ]; +} diff --git a/modules/dev/javascript.nix b/modules/dev/javascript.nix index 304d927..dd29a6d 100644 --- a/modules/dev/javascript.nix +++ b/modules/dev/javascript.nix @@ -14,11 +14,12 @@ in { pnpm yarn - tsdx - mklicense - preact-cli - create-next-app - create-snowpack-app - bower + /* tsdx + mklicense + preact-cli + create-next-app + create-snowpack-app + bower + */ ]; } diff --git a/modules/overlay.nix b/modules/overlay.nix index ca54717..9f8a50b 100644 --- a/modules/overlay.nix +++ b/modules/overlay.nix @@ -27,12 +27,15 @@ in { # unstable stuff brave = unstable.brave; + idris2 = unstable.idris2; ngrok = unstable.ngrok; vscodium = unstable.vscodium; + vscode = unstable.vscode; docker-compose = unstable.docker-compose; deno = unstable.deno; + # discord = unstable.discord; discord-canary = unstable.discord-canary; - dotnet-sdk = dotnet-sdk_3; + dotnet-sdk = unstable.dotnet-sdk_5; elm-repl = unstable.haskellPackages.elm-repl; }) ]; diff --git a/nix/sources.json b/nix/sources.json index 1a9bed5..7e07a50 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -5,10 +5,10 @@ "homepage": "", "owner": "nix-community", "repo": "NUR", - "rev": "05a29a61a994685404ce141957c99ac65628ec25", - "sha256": "143nh2ag1dj67vg66wdmkscxa7xfic7balxg0hvymvhzzp18rbw2", + "rev": "cfe9e2e5ae53250337b0ffb3f39b477ca09cd232", + "sha256": "1zr8mcxp6gpiv7hy7g94giry0gfak8rbvmsi4f8vrry0jvvhp8x7", "type": "tarball", - "url": "https://github.com/nix-community/NUR/archive/05a29a61a994685404ce141957c99ac65628ec25.tar.gz", + "url": "https://github.com/nix-community/NUR/archive/cfe9e2e5ae53250337b0ffb3f39b477ca09cd232.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "agnoster": { @@ -17,10 +17,10 @@ "homepage": null, "owner": "oh-my-fish", "repo": "theme-agnoster", - "rev": "99d4e9f1b6bb1c828155495bddf3e0f0516e35f1", - "sha256": "0vyg30zi3xhl7m2y40ihb7ikwifz5ifq5wq0y58rz9hpb19wf8ws", + "rev": "43860ce1536930bca689470e26083b0a5b7bd6ae", + "sha256": "16k94hz3s6wayass6g1lhlcjmbpf2w8mzx90qrrqp120h80xwp25", "type": "tarball", - "url": "https://github.com/oh-my-fish/theme-agnoster/archive/99d4e9f1b6bb1c828155495bddf3e0f0516e35f1.tar.gz", + "url": "https://github.com/oh-my-fish/theme-agnoster/archive/43860ce1536930bca689470e26083b0a5b7bd6ae.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "all-hies": { @@ -29,10 +29,10 @@ "homepage": "", "owner": "Infinisil", "repo": "all-hies", - "rev": "09ba836904fa290b5e37d5403150ea0c921661fb", - "sha256": "0qbjqv1fkhkx1cffqybz1mfks1jphh0vh3zd8ad2qd6lch4gyys4", + "rev": "2364c7bdf5eec60a4765486d16f9ae6be5cd8a78", + "sha256": "083k1xxjpdgfkbvadbw6sdbll52807iwzs1fsy1b5axjijsc5qgh", "type": "tarball", - "url": "https://github.com/Infinisil/all-hies/archive/09ba836904fa290b5e37d5403150ea0c921661fb.tar.gz", + "url": "https://github.com/Infinisil/all-hies/archive/2364c7bdf5eec60a4765486d16f9ae6be5cd8a78.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "cached-nix-shell": { @@ -41,10 +41,10 @@ "homepage": "", "owner": "xzfc", "repo": "cached-nix-shell", - "rev": "48dbef37bec653e23c1801cea3979f053e10654b", - "sha256": "0w6khry1ncyqy5h6996xw1f6viw4wdrfji5m8lz9gm487xlq5v0b", + "rev": "8b87dc0047f35fec4f7a132d0e1b67d0526a22f5", + "sha256": "1cryshs5w67xg8j3dsy3z4ia6hxzdv6jzz25jwd1m27jci4035qy", "type": "tarball", - "url": "https://github.com/xzfc/cached-nix-shell/archive/48dbef37bec653e23c1801cea3979f053e10654b.tar.gz", + "url": "https://github.com/xzfc/cached-nix-shell/archive/8b87dc0047f35fec4f7a132d0e1b67d0526a22f5.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "easy-dhall-nix": { @@ -53,10 +53,10 @@ "homepage": "", "owner": "justinwoo", "repo": "easy-dhall-nix", - "rev": "3e9101c5dfd69a9fc28fe4998aff378f91bfcb64", - "sha256": "1nsn1n4sx4za6jipcid1293rdw8lqgj9097s0khiij3fz0bzhrg9", + "rev": "1f6eecab5c276a59858a10bbfcbbc5611187da03", + "sha256": "07n7y93xfiwr82yx2v8r5mxcafsxgs1hdl1ghq6xah5v827fb6q0", "type": "tarball", - "url": "https://github.com/justinwoo/easy-dhall-nix/archive/3e9101c5dfd69a9fc28fe4998aff378f91bfcb64.tar.gz", + "url": "https://github.com/justinwoo/easy-dhall-nix/archive/1f6eecab5c276a59858a10bbfcbbc5611187da03.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "easy-purescript-nix": { @@ -65,10 +65,10 @@ "homepage": "", "owner": "justinwoo", "repo": "easy-purescript-nix", - "rev": "7ff5a12af5750f94d0480059dba0ba6b82c6c452", - "sha256": "0af25dqhs13ii4mx9jjkx2pww4ddbs741vb5gfc5ckxb084d69fq", + "rev": "47bdc016c7d56e987ca1aca690b1d6c9816a8584", + "sha256": "051fzxd03y0c63sll2bhn0h66dywy9lw6ylyh5vq8fymvix20q94", "type": "tarball", - "url": "https://github.com/justinwoo/easy-purescript-nix/archive/7ff5a12af5750f94d0480059dba0ba6b82c6c452.tar.gz", + "url": "https://github.com/justinwoo/easy-purescript-nix/archive/47bdc016c7d56e987ca1aca690b1d6c9816a8584.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "home-manager": { @@ -77,10 +77,10 @@ "homepage": "https://rycee.gitlab.io/home-manager/", "owner": "rycee", "repo": "home-manager", - "rev": "318bc0754ed6370cfcae13183a7f13f7aa4bc73f", - "sha256": "0hgn85yl7gixw1adjfa9nx8axmlpw5y1883lzg3zigknx6ff5hsr", + "rev": "e6f96b6aa3e99495f9f6f3488ecf78dd316e5bec", + "sha256": "1xvxqw5cldlhcl7xsbw11n2s3x1h2vmbm1b9b69a641rzj3srg11", "type": "tarball", - "url": "https://github.com/rycee/home-manager/archive/318bc0754ed6370cfcae13183a7f13f7aa4bc73f.tar.gz", + "url": "https://github.com/rycee/home-manager/archive/e6f96b6aa3e99495f9f6f3488ecf78dd316e5bec.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "niv": { @@ -89,10 +89,10 @@ "homepage": "https://github.com/nmattia/niv", "owner": "nmattia", "repo": "niv", - "rev": "303f442c43f918bc43400ab4a0b662a82ca7748b", - "sha256": "19z1qypd6zd4qzhrhjm7j55v85fzf8wln8l9vslvn9dpspcwxv7c", + "rev": "e0ca65c81a2d7a4d82a189f1e23a48d59ad42070", + "sha256": "1pq9nh1d8nn3xvbdny8fafzw87mj7gsmp6pxkdl65w2g18rmcmzx", "type": "tarball", - "url": "https://github.com/nmattia/niv/archive/303f442c43f918bc43400ab4a0b662a82ca7748b.tar.gz", + "url": "https://github.com/nmattia/niv/archive/e0ca65c81a2d7a4d82a189f1e23a48d59ad42070.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "nixpkgs": { @@ -101,22 +101,22 @@ "homepage": "https://github.com/NixOS/nixpkgs", "owner": "NixOS", "repo": "nixpkgs-channels", - "rev": "0c0fe6d85b92c4e992e314bd6f9943413af9a309", - "sha256": "03q0dzxpd55xmvxzr963hv3nxh57m5d7sgiw5kvhpms1hf8lwd4r", + "rev": "6d1a044fc9ff3cc96fca5fa3ba9c158522bbf2a5", + "sha256": "07a3nyrj3pwl017ig0rbn5rbmbf14gl3vqggvkyrdby01726p5fg", "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs-channels/archive/0c0fe6d85b92c4e992e314bd6f9943413af9a309.tar.gz", + "url": "https://github.com/NixOS/nixpkgs-channels/archive/6d1a044fc9ff3cc96fca5fa3ba9c158522bbf2a5.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "nixpkgs-unstable": { "branch": "nixos-unstable", - "description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to", - "homepage": "https://github.com/NixOS/nixpkgs", - "owner": "nixos", - "repo": "nixpkgs-channels", - "rev": "8e2b14aceb1d40c7e8b84c03a7c78955359872bb", - "sha256": "0zzjpd9smr7rxzrdf6raw9kbj42fbvafxb5bz36lcxgv290pgsm8", + "description": "Nix Packages collection", + "homepage": "", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "7e567a3d092b7de69cdf5deaeb8d9526de230916", + "sha256": "0gnbxg435pnp727gbakifqkjnf2pm7qsq2b6767rj4si4w60v96v", "type": "tarball", - "url": "https://github.com/nixos/nixpkgs-channels/archive/8e2b14aceb1d40c7e8b84c03a7c78955359872bb.tar.gz", + "url": "https://github.com/NixOS/nixpkgs/archive/7e567a3d092b7de69cdf5deaeb8d9526de230916.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "snack": { @@ -125,10 +125,10 @@ "homepage": "", "owner": "nmattia", "repo": "snack", - "rev": "b638463b9a7490867b44d0c33bb02e8f7ca82f29", - "sha256": "02h4f0nrjvhsm7hvmrnc4kfi5my48d7yvind0f1kq1lsrcch6iph", + "rev": "2c490a259a7670192744021fb87bf7e430a4e7f0", + "sha256": "1v9b9bimw2nx0f2v94hjxlmsb7s82idrpc9dvjabqm92f9yc3kx9", "type": "tarball", - "url": "https://github.com/nmattia/snack/archive/b638463b9a7490867b44d0c33bb02e8f7ca82f29.tar.gz", + "url": "https://github.com/nmattia/snack/archive/2c490a259a7670192744021fb87bf7e430a4e7f0.tar.gz", "url_template": "https://github.com///archive/.tar.gz" } } diff --git a/nix/sources.nix b/nix/sources.nix index 7bd0f3e..1938409 100644 --- a/nix/sources.nix +++ b/nix/sources.nix @@ -6,25 +6,33 @@ let # The fetchers. fetch_ fetches specs of type . # - fetch_file = pkgs: spec: - if spec.builtin or true then - builtins_fetchurl { inherit (spec) url sha256; } - else - pkgs.fetchurl { inherit (spec) url sha256; }; + 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 - ok = str: ! builtins.isNull (builtins.match "[a-zA-Z0-9+-._?=]" str); - # sanitize the name, though nix will still fail if name starts with period - name' = stringAsChars (x: if ! ok x then "-" else x) "${name}-src"; + 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 = spec: - builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; }; + 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; @@ -40,11 +48,21 @@ let # 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: + mkPkgs = sources: system: let sourcesNixpkgs = - import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) {}; + import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; }; hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; hasThisAsNixpkgsPath = == ./.; in @@ -64,15 +82,27 @@ let 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 spec + 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 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 @@ -89,25 +119,29 @@ let # 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, sha256 }@attrs: + builtins_fetchTarball = { url, name ? null, sha256 }@attrs: let inherit (builtins) lessThan nixVersion fetchTarball; in if lessThan nixVersion "1.12" then - fetchTarball { inherit name url; } + 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, sha256 }@attrs: + builtins_fetchurl = { url, name ? null, sha256 }@attrs: let inherit (builtins) lessThan nixVersion fetchurl; in if lessThan nixVersion "1.12" then - fetchurl { inherit url; } + fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) else fetchurl attrs; @@ -119,14 +153,15 @@ let then abort "The values in sources.json should not have an 'outPath' attribute" else - spec // { outPath = fetch config.pkgs name spec; } + spec // { outPath = replace name (fetch config.pkgs name spec); } ) config.sources; # The "config" used by the fetchers mkConfig = - { sourcesFile ? ./sources.json - , sources ? builtins.fromJSON (builtins.readFile sourcesFile) - , pkgs ? mkPkgs sources + { 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; @@ -134,5 +169,6 @@ let # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers inherit pkgs; }; + in mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }