diff --git a/.gitignore b/.gitignore index 8a2be67a49..e02fc7f2b2 100644 --- a/.gitignore +++ b/.gitignore @@ -24,5 +24,7 @@ dist-newstyle # Mac developers **/.DS_Store - /libb2.dylib + +# Nix +result diff --git a/development.markdown b/development.markdown index 22e9657c74..962a507c63 100644 --- a/development.markdown +++ b/development.markdown @@ -126,9 +126,9 @@ This is specified with the normal Some examples: ``` -nix build '.#haskell-nix.unison-cli:lib:unison-cli' -nix build '.#haskell-nix.unison-syntax:test:syntax-tests' -nix build '.#haskell-nix.unison-cli:exe:transcripts' +nix build '.#component-unison-cli:lib:unison-cli' +nix build '.#component-unison-syntax:test:syntax-tests' +nix build '.#component-unison-cli:exe:transcripts' ``` ### Development environments @@ -154,7 +154,7 @@ all non-local haskell dependencies (including profiling dependencies) are provided in the nix shell. ``` -nix develop '.#haskell-nix.local' +nix develop '.#cabal-local' ``` #### Get into a development environment for building a specific package @@ -164,17 +164,17 @@ all haskell dependencies of this package are provided by the nix shell (including profiling dependencies). ``` -nix develop '.#haskell-nix.' +nix develop '.#cabal-' ``` for example: ``` -nix develop '.#haskell-nix.unison-cli' +nix develop '.#cabal-unison-cli' ``` or ``` -nix develop '.#haskell-nix.unison-parser-typechecker' +nix develop '.#cabal-unison-parser-typechecker' ``` This is useful if you wanted to profile a package. For example, if you @@ -183,7 +183,7 @@ shells, cd into its directory, then run the program with profiling. ``` -nix develop '.#unison-parser-typechecker' +nix develop '.#cabal-unison-parser-typechecker' cd unison-cli cabal run --enable-profiling unison-cli-main:exe:unison -- +RTS -p ``` diff --git a/flake.nix b/flake.nix index a9628dc4ad..740109dd10 100644 --- a/flake.nix +++ b/flake.nix @@ -88,42 +88,50 @@ ''; }; }; + + renameAttrs = fn: nixpkgs.lib.mapAttrs' (name: value: { + inherit value; + name = fn name;}); in assert nixpkgs-packages.ormolu.version == versions.ormolu; assert nixpkgs-packages.hls.version == versions.hls; assert nixpkgs-packages.unwrapped-stack.version == versions.stack; assert nixpkgs-packages.hpack.version == versions.hpack; { - packages = nixpkgs-packages // { - default = haskell-nix-flake.defaultPackage; - haskell-nix = haskell-nix-flake.packages; - docker = import ./nix/docker.nix { inherit pkgs; haskell-nix = haskell-nix-flake.packages; }; - build-tools = pkgs.symlinkJoin { - name = "build-tools"; - paths = self.devShells."${system}".only-tools-nixpkgs.buildInputs; - }; - all = pkgs.symlinkJoin { - name = "all"; - paths = - let - all-other-packages = builtins.attrValues (builtins.removeAttrs self.packages."${system}" [ "all" "build-tools" ]); - devshell-inputs = builtins.concatMap - (devShell: devShell.buildInputs ++ devShell.nativeBuildInputs) - [ - self.devShells."${system}".only-tools-nixpkgs - ]; - in - all-other-packages ++ devshell-inputs; + packages = + nixpkgs-packages + // renameAttrs (name: "component-${name}") haskell-nix-flake.packages + // renameAttrs (name: "docker-${name}") (import ./nix/docker.nix { inherit pkgs; haskell-nix = haskell-nix-flake.packages; }) + // { + default = haskell-nix-flake.defaultPackage; + build-tools = pkgs.symlinkJoin { + name = "build-tools"; + paths = self.devShells."${system}".only-tools-nixpkgs.buildInputs; + }; + all = pkgs.symlinkJoin { + name = "all"; + paths = + let + all-other-packages = builtins.attrValues (builtins.removeAttrs self.packages."${system}" [ "all" "build-tools" ]); + devshell-inputs = builtins.concatMap + (devShell: devShell.buildInputs ++ devShell.nativeBuildInputs) + [ + self.devShells."${system}".only-tools-nixpkgs + ]; + in + all-other-packages ++ devshell-inputs; + }; }; - }; - apps = haskell-nix-flake.apps // { - default = self.apps."${system}"."unison-cli-main:exe:unison"; + apps = renameAttrs (name: "component-${name}") haskell-nix-flake.apps // { + default = self.apps."${system}"."component-unison-cli-main:exe:unison"; }; - devShells = nixpkgs-devShells // { - default = self.devShells."${system}".only-tools-nixpkgs; - haskell-nix = haskell-nix-flake.devShells; - }; + devShells = + nixpkgs-devShells + // renameAttrs (name: "cabal-${name}") haskell-nix-flake.devShells + // { + default = self.devShells."${system}".only-tools-nixpkgs; + }; }); } diff --git a/nix/docker.nix b/nix/docker.nix index 4017a792d6..bfd4751e4f 100644 --- a/nix/docker.nix +++ b/nix/docker.nix @@ -5,6 +5,6 @@ name = "ucm"; tag = "latest"; contents = with pkgs; [ cacert fzf ]; - config.Cmd = [ "${haskell-nix."unison-cli:exe:unison"}/bin/unison" ]; + config.Cmd = [ "${haskell-nix."unison-cli-main:exe:unison"}/bin/unison" ]; }; }