Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: software feels very uncomfortable to use #270

Open
sjmackenzie opened this issue May 25, 2019 · 4 comments
Open

Problem: software feels very uncomfortable to use #270

sjmackenzie opened this issue May 25, 2019 · 4 comments

Comments

@sjmackenzie
Copy link
Member

sjmackenzie commented May 25, 2019

Is there a way I can do something like this:

{ pkgs ? import <nixpkgs> {}}:

# pull in racket2nix src

pkgs.stdenv.mkDerivation {
  name = "fractalide-paper";
  src = ./.;
  buildInputs = [ racket73Packages.base racket73Packages.scribble-lib ];

  buildPhase = ''
    scribble --pdf fractalide.scrbl
  '';
  installPhase = ''
    mkdir $out
    mv fractalide.pdf $out
  '';
}
@sjmackenzie sjmackenzie changed the title Problem: software is feels very uncomfortable to use Problem: software feels very uncomfortable to use May 25, 2019
@sjmackenzie
Copy link
Member Author

At the moment I have something like this:

{ pkgs ? import <nixpkgs> {}
, racket2nix ? pkgs.fetchFromGitHub {
  owner = "fractalide"; repo = "racket2nix";
  rev = "0cafac6fbebed544c6118a53fce3d0972c900769";
  sha256 = "142kh5ispik87fah5wgvnaih3yqg1ajqpb0ipaxbxv7wrdmn0ziw"; }
}:
with pkgs;
let
  inherit (racket2nix) buildRacketPackage;
  latex = texlive.combine { inherit (texlive) scheme-full;};
  pdf = (buildRacketPackage (builtins.path {
    name = "pdf";
    path = ./.;
  })).overrideAttrs (oldAttrs: {
    buildInputs = oldAttrs.buildInputs or [] ++ [ latex ];
    postInstall = oldAttrs.postInstall or "" + ''
      scribble --pdf pdf.scrbl
      mkdir $out
      mv pdf.pdf $out
    '';
  });
in
pdf

and I get this error:

$ nix-build
error: attribute 'buildRacketPackage' missing, at path/to/default.nix:8:4

@clacke
Copy link
Member

clacke commented May 25, 2019

The first thing: Yeah, the big thing missing here is a nice racket.withPackages. That's not too far off in the future, I'm reworking the whole buildPhase (actually making a buildPhase at all rather than building everything in installPhase), and that's going to make this easy to add.

@clacke
Copy link
Member

clacke commented May 25, 2019

The second thing: It needs to be inherit (import racket2nix {}) buildRacketPackage, but that still won't work, because your derivation won't have the scribble tool in its $PATH.

If you don't rely on any specific packages in your .scrbl you can get away with something like:

{ pkgs ? import <nixpkgs> {}
, racket2nix ? pkgs.fetchFromGitHub {
  owner = "fractalide"; repo = "racket2nix";
  rev = "0cafac6fbebed544c6118a53fce3d0972c900769";
  sha256 = "142kh5ispik87fah5wgvnaih3yqg1ajqpb0ipaxbxv7wrdmn0ziw"; }
}:

with pkgs;

runCommand "pdf.pdf" {
  buildInputs = [
    (import racket2nix { package = "scribble-lib"; })  # shortcut "documented" in test.nix but not in human-friendly docs
    (texlive.combine { inherit (texlive) scheme-full;})
  ];
} ''
  cp ${./pdf.scrbl} pdf.scrbl
  scribble --pdf pdf.scrbl
  mv pdf.pdf $out
''

But if you are documenting an API and you need a bunch of collections installed to interpret the .scrbl, I'm afraid you'll have to take the scribble-lib derivation, overrideRacketDerivation it and augment racketThinBuildInputs with everything you need (but at least using *Thin* takes care of the transitive dependencies!). There's a lot of potential for improvement here, but basically that's all captured by the glorious future racket.withPackages.

@clacke
Copy link
Member

clacke commented May 25, 2019

#158

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants