matthuszagh / nixos

Personal nixos dotfiles
MIT License
5 stars 0 forks source link

TODO describe how to use mach-nix at system level and project level.

*** Jupyter :PROPERTIES: :ID: bd03fa65-c5b9-451c-939d-e201858218a0 :END: TODO describe how to use Jupyter.

** Rust :PROPERTIES: :ID: 53d828ea-4f4d-4c95-961f-75bc2c418d8f :END:

There are several simple steps for adding a package from a different version of nixpkgs. This works on new packages (i.e. not available in the main nixpkgs flake) and different versions of existing packages, which override those in the main nixpkgs flake without requiring you to write an overlay.

First, add the repo + branch as an input and then add it to the function argument of outputs. Finally, add the package to the ~overridePkgs~ attribute set. Here's an example:

+begin_src nix :eval no

{ inputs = { nixpkgs.url = "github:nixos/nixpkgs/master"; home.url = "github:rycee/home-manager/bqv-flakes"; emacsOverlay.url = "github:nix-community/emacs-overlay";

package overrides

sageNixpkgs.url = "github:nixos/nixpkgs/7866440f1223dc447f38cb23c00e10b44b4c98fe";
paraviewNixpkgs.url = "github:nixos/nixpkgs/72158c231ae46a34ec16b8134d2a8598506acd9c";
anystyleNixpkgs.url = "github:SCOTT-HAMILTON/nixpkgs/4cf6c95cb021b62e78e769af7ba64280b340b666";
vivadoNixpkgs.url = "github:matthuszagh/nixpkgs/vivado";

};

outputs = { self , nixpkgs , home , emacsOverlay , sageNixpkgs , paraviewNixpkgs , anystyleNixpkgs , vivadoNixpkgs }: let inherit (builtins) attrNames attrValues readDir; inherit (nixpkgs) lib; inherit (lib) recursiveUpdate genAttrs mapAttrs' nameValuePair; inherit (utils) pathsToImportedAttrs;

  utils = import ./lib/utils.nix { inherit lib; };

  system = "x86_64-linux";

  externalOverlays = [
    emacsOverlay.overlay
  ];

  pkgImport = pkgs: import pkgs {
    inherit system;
    # Order is significant. First incorporate external overlays. We
    # can then use and override these in custom packages (defined
    # in `self.overlay`). Finally overlays in ./overlays can
    # override everything else.
    overlays = externalOverlays
      ++ [ self.overlay ]
      ++ (attrValues self.overlays);
    config = { allowUnfree = true; };
  };

  overridePkgs = {
    sageWithDoc = (pkgImport sageNixpkgs).sageWithDoc;
    paraview = (pkgImport paraviewNixpkgs).paraview;
    anystyle-cli = (pkgImport anystyleNixpkgs).anystyle-cli;
    vivado = (pkgImport vivadoNixpkgs).vivado;
  };

  pkgs = (pkgImport nixpkgs) // overridePkgs;
  [...]

+end_src

+begin_src bash :eval no

git subtree push --prefix=users/profiles/emacs/emacs emacs master

+end_src