summary refs log tree commit diff
path: root/pkgs/build-support/agda/default.nix
diff options
context:
space:
mode:
authorJohn Ericson <Ericson2314@Yahoo.com>2015-05-30 19:22:32 +0000
committerJohn Ericson <Ericson2314@Yahoo.com>2015-05-30 19:22:32 +0000
commit21b10ab44fa8f28f36990085853d9d2708d694db (patch)
treeb3d86177b414b5bf20dcbea695db30666fbf4e01 /pkgs/build-support/agda/default.nix
parentc1f5748983ab0e71af4421030a40ac424e666b45 (diff)
downloadnixpkgs-21b10ab44fa8f28f36990085853d9d2708d694db.tar
nixpkgs-21b10ab44fa8f28f36990085853d9d2708d694db.tar.gz
nixpkgs-21b10ab44fa8f28f36990085853d9d2708d694db.tar.bz2
nixpkgs-21b10ab44fa8f28f36990085853d9d2708d694db.tar.lz
nixpkgs-21b10ab44fa8f28f36990085853d9d2708d694db.tar.xz
nixpkgs-21b10ab44fa8f28f36990085853d9d2708d694db.tar.zst
nixpkgs-21b10ab44fa8f28f36990085853d9d2708d694db.zip
agda: `postprocess` and `defaults` need not be in the scope of args
Diffstat (limited to 'pkgs/build-support/agda/default.nix')
-rw-r--r--pkgs/build-support/agda/default.nix161
1 files changed, 80 insertions, 81 deletions
diff --git a/pkgs/build-support/agda/default.nix b/pkgs/build-support/agda/default.nix
index a404bbcf634..74debe79efc 100644
--- a/pkgs/build-support/agda/default.nix
+++ b/pkgs/build-support/agda/default.nix
@@ -14,87 +14,86 @@ let
   concatMapStrings = stdenv.lib.strings.concatMapStrings;
   unwords = stdenv.lib.strings.concatStringsSep " ";
   mapInside = xs: unwords (map (x: x + "/*") xs);
-in
-{ mkDerivation = args:
-    let
-      postprocess = x: x // {
-        sourceDirectories = filter (y: !(y == null)) x.sourceDirectories;
-        propagatedBuildInputs = filter (y : ! (y == null)) x.propagatedBuildInputs;
-        propagatedUserEnvPkgs = filter (y : ! (y == null)) x.propagatedUserEnvPkgs;
-        everythingFile = if x.everythingFile == "" then "Everything.agda" else x.everythingFile;
-      };
 
-      defaults = self : {
-        # There is no Hackage for Agda so we require src.
-        inherit (self) src name;
-
-        isAgdaPackage = true;
-
-        buildInputs = [ Agda ] ++ self.buildDepends;
-        buildDepends = [];
-
-        buildDependsAgda = filter
-          (dep: dep ? isAgdaPackage && dep.isAgdaPackage)
-          self.buildDepends;
-        buildDependsAgdaShareAgda = map (x: x + "/share/agda") self.buildDependsAgda;
-
-        # Not much choice here ;)
-        LANG = "en_US.UTF-8";
-        LOCALE_ARCHIVE = optionalString stdenv.isLinux "${glibcLocales}/lib/locale/locale-archive";
-
-        everythingFile = "Everything.agda";
-
-        propagatedBuildInputs = self.buildDependsAgda;
-        propagatedUserEnvPkgs = self.buildDependsAgda;
-
-        # Immediate source directories under which modules can be found.
-        sourceDirectories = [ ];
-
-        # This is used if we have a top-level element that only serves
-        # as the container for the source and we only care about its
-        # contents. The directories put here will have their
-        # *contents* copied over as opposed to sourceDirectories which
-        # would make a direct copy of the whole thing.
-        topSourceDirectories = [ "src" ];
-
-        # FIXME: `dirOf self.everythingFile` is what we really want, not hardcoded "./"
-        includeDirs = self.buildDependsAgdaShareAgda
-                      ++ self.sourceDirectories ++ self.topSourceDirectories
-                      ++ [ "." ];
-        buildFlags = unwords (map (x: "-i " + x) self.includeDirs);
-
-        agdaWithArgs = "${Agda}/bin/agda ${self.buildFlags}";
-
-        buildPhase = ''
-          runHook preBuild
-          ${self.agdaWithArgs} ${self.everythingFile}
-          runHook postBuild
-        '';
-
-        installPhase = ''
-          runHook preInstall
-          mkdir -p $out/share/agda
-          cp -pR ${unwords self.sourceDirectories} ${mapInside self.topSourceDirectories} $out/share/agda
-          runHook postInstall
-        '';
-
-        passthru = {
-          env = stdenv.mkDerivation {
-            name = "interactive-${self.name}";
-            inherit (self) LANG LOCALE_ARCHIVE;
-            AGDA_PACKAGE_PATH = concatMapStrings (x: x + ":") self.buildDependsAgdaShareAgda;
-            buildInputs = let
-              # Makes a wrapper available to the user. Very useful in
-              # nix-shell where all dependencies are -i'd.
-              agdaWrapper = writeScriptBin "agda" ''
-                ${self.agdaWithArgs} "$@"
-              '';
-            in [agdaWrapper] ++ self.buildDepends;
-          };
-        };
+  defaults = self : {
+    # There is no Hackage for Agda so we require src.
+    inherit (self) src name;
+
+    isAgdaPackage = true;
+
+    buildInputs = [ Agda ] ++ self.buildDepends;
+    buildDepends = [];
+
+    buildDependsAgda = filter
+      (dep: dep ? isAgdaPackage && dep.isAgdaPackage)
+      self.buildDepends;
+    buildDependsAgdaShareAgda = map (x: x + "/share/agda") self.buildDependsAgda;
+
+    # Not much choice here ;)
+    LANG = "en_US.UTF-8";
+    LOCALE_ARCHIVE = optionalString stdenv.isLinux "${glibcLocales}/lib/locale/locale-archive";
+
+    everythingFile = "Everything.agda";
+
+    propagatedBuildInputs = self.buildDependsAgda;
+    propagatedUserEnvPkgs = self.buildDependsAgda;
+
+    # Immediate source directories under which modules can be found.
+    sourceDirectories = [ ];
+
+    # This is used if we have a top-level element that only serves
+    # as the container for the source and we only care about its
+    # contents. The directories put here will have their
+    # *contents* copied over as opposed to sourceDirectories which
+    # would make a direct copy of the whole thing.
+    topSourceDirectories = [ "src" ];
+
+    # FIXME: `dirOf self.everythingFile` is what we really want, not hardcoded "./"
+    includeDirs = self.buildDependsAgdaShareAgda
+                  ++ self.sourceDirectories ++ self.topSourceDirectories
+                  ++ [ "." ];
+    buildFlags = unwords (map (x: "-i " + x) self.includeDirs);
+
+    agdaWithArgs = "${Agda}/bin/agda ${self.buildFlags}";
+
+    buildPhase = ''
+      runHook preBuild
+      ${self.agdaWithArgs} ${self.everythingFile}
+      runHook postBuild
+    '';
+
+    installPhase = ''
+      runHook preInstall
+      mkdir -p $out/share/agda
+      cp -pR ${unwords self.sourceDirectories} ${mapInside self.topSourceDirectories} $out/share/agda
+      runHook postInstall
+    '';
+
+    passthru = {
+      env = stdenv.mkDerivation {
+        name = "interactive-${self.name}";
+        inherit (self) LANG LOCALE_ARCHIVE;
+        AGDA_PACKAGE_PATH = concatMapStrings (x: x + ":") self.buildDependsAgdaShareAgda;
+        buildInputs = let
+          # Makes a wrapper available to the user. Very useful in
+          # nix-shell where all dependencies are -i'd.
+          agdaWrapper = writeScriptBin "agda" ''
+            ${self.agdaWithArgs} "$@"
+          '';
+        in [agdaWrapper] ++ self.buildDepends;
       };
-    in stdenv.mkDerivation
-         (postprocess (let super = defaults self // args self;
-                           self  = super // extension self super;
-                       in self));
+    };
+  };
+
+  postprocess = x: x // {
+    sourceDirectories = filter (y: !(y == null)) x.sourceDirectories;
+    propagatedBuildInputs = filter (y : ! (y == null)) x.propagatedBuildInputs;
+    propagatedUserEnvPkgs = filter (y : ! (y == null)) x.propagatedUserEnvPkgs;
+    everythingFile = if x.everythingFile == "" then "Everything.agda" else x.everythingFile;
+  };
+in
+{ mkDerivation = args: let
+      super = defaults self // args self;
+      self  = super // extension self super;
+    in stdenv.mkDerivation (postprocess self);
 }