about summary refs log tree commit diff
path: root/pkgs/development/embedded
diff options
context:
space:
mode:
authorJan Malakhovski <oxij@oxij.org>2023-08-08 17:18:01 +0000
committerAnderson Torres <torres.anderson.85@protonmail.com>2023-08-11 09:20:44 +0000
commit591ccfe5b9bd6d9747c264a1aa5d324bc1cdc7dd (patch)
tree73149b019a95f280384d180b5b8165e7b11eedaa /pkgs/development/embedded
parent979f71ba7c542928f8a7029c12da8c9ba16c2787 (diff)
treewide: noop: refer to `src.name` or similar where appropriate, part 3: more use cases
This continues where d8f7f6a5cee067b81bfaaa3aa079adb94ed7c01e left off. Similarly
to that commit, this commit this also points `sourceRoot`s to `src.name` and similar
instead of keeping hardcoded names, and edits other derivation attrs do do the same,
where appropriate.

Also, similarly to d8f7f6a5cee067b81bfaaa3aa079adb94ed7c01e some of expressions this
edits use `srcs` attribute with customly-named sources, so they have to be moved
into `let` blocks to keep evaluation efficient (the other, worse, way to do this
would to recurcively refer to `elemAt n finalAttrs.srcs` or, similarly, with `rec`).
Diffstat (limited to 'pkgs/development/embedded')
-rw-r--r--pkgs/development/embedded/fpga/trellis/default.nix39
1 files changed, 20 insertions, 19 deletions
diff --git a/pkgs/development/embedded/fpga/trellis/default.nix b/pkgs/development/embedded/fpga/trellis/default.nix
index 566bf5bdf7550..f0ff4a47b4c35 100644
--- a/pkgs/development/embedded/fpga/trellis/default.nix
+++ b/pkgs/development/embedded/fpga/trellis/default.nix
@@ -4,28 +4,29 @@ let
   rev = "488f4e71073062de314c55a037ede7cf03a3324c";
   # git describe --tags
   realVersion = "1.2.1-14-g${builtins.substring 0 7 rev}";
+
+  main_src = fetchFromGitHub {
+    owner  = "YosysHQ";
+    repo   = "prjtrellis";
+    inherit rev;
+    hash   = "sha256-Blbu+0rlM/3izbF0XCvkNpSAND0IclWEwK7anzyrpvw=";
+    name   = "trellis";
+  };
+
+  database_src = fetchFromGitHub {
+    owner  = "YosysHQ";
+    repo   = "prjtrellis-db";
+    rev    = "35d900a94ff0db152679a67bf6e4fbf40ebc34aa";
+    hash   = "sha256-r6viR8y9ZjURGNbsa0/YY8lzy9kGzjuu408ntxwpqm0=";
+    name   = "trellis-database";
+  };
+
 in stdenv.mkDerivation rec {
   pname = "trellis";
   version = "unstable-2022-09-14";
 
-  srcs = [
-    (fetchFromGitHub {
-       owner  = "YosysHQ";
-       repo   = "prjtrellis";
-       inherit rev;
-       hash   = "sha256-Blbu+0rlM/3izbF0XCvkNpSAND0IclWEwK7anzyrpvw=";
-       name   = "trellis";
-     })
-
-    (fetchFromGitHub {
-      owner  = "YosysHQ";
-      repo   = "prjtrellis-db";
-      rev    = "35d900a94ff0db152679a67bf6e4fbf40ebc34aa";
-      hash   = "sha256-r6viR8y9ZjURGNbsa0/YY8lzy9kGzjuu408ntxwpqm0=";
-      name   = "trellis-database";
-    })
-  ];
-  sourceRoot = "trellis";
+  srcs = [ main_src database_src ];
+  sourceRoot = main_src.name;
 
   buildInputs = [ boost ];
   nativeBuildInputs = [ cmake python3 ];
@@ -36,7 +37,7 @@ in stdenv.mkDerivation rec {
   ];
 
   preConfigure = ''
-    rmdir database && ln -sfv ${builtins.elemAt srcs 1} ./database
+    rmdir database && ln -sfv ${database_src} ./database
 
     cd libtrellis
   '';