;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (byte-code "\300\301!\210\300\302!\210\303\304\305\306\307\310\311\312&\210\313\314\305\315\311\304\316\317&\207" [require dash s custom-declare-group nix nil "customizations for nix" :prefix "nix-" :group external custom-declare-variable nix-nixpkgs-path "Absolute path to a nixpkgs directory.\n\nCan be customized to select a nix-channel\ne.g. /home/user/.nix-defexpr/channels/unstable/nixpkgs" :type (choice (const :tag "No channel" nil) (directory "Custom path to a nixpkgs distribution"))] 8) #@72 Create a new rc file containing the environment for the given SANDBOX. (defalias 'nix-create-sandbox-rc #[(sandbox) "\304\203\305 \203\306 P\206\307\310\311!\312\260\202\313!\314\315!\316 \317\n\320$\210\n*\207" [sandbox nix-nixpkgs-path tmp-file env-str shell-command-to-string "nix-shell " "-I nixpkgs=" "" " --run 'declare +x shellHook; declare -x; declare -xf' " shell-quote-argument " 2> /dev/null" "bash -c 'declare +x shellHook; declare -x; declare -xf'" make-temp-file "nix-sandbox-rc-" write-region nil append] 6 (#$ . 587)]) (defvar nix-sandbox-rc-map (make-hash-table :test 'equal :size 4)) #@57 Return the rc file for the given SANDBOX or create one. (defalias 'nix-sandbox-rc #[(sandbox) "\302 \"\206\303\304! #\207" [sandbox nix-sandbox-rc-map gethash puthash nix-create-sandbox-rc] 4 (#$ . 1208)]) #@77 Assemble a command from ARGS that can be executed in the specified SANDBOX. (defalias 'nix-shell-command #[(sandbox &rest args) "\302\303\304\305\306!\307\310 \311##E\207" [sandbox args "bash" "-c" format "source %s; %s" nix-sandbox-rc mapconcat shell-quote-argument " "] 9 (#$ . 1425)]) #@83 Assemble a command string from ARGS that can be executed in the specifed SANDBOX. (defalias 'nix-shell-string #[(sandbox &rest args) "\302\303\304 #!\207" [sandbox args combine-and-quote-strings apply nix-shell-command] 5 (#$ . 1720)]) #@55 Compile a program using the given COMMAND in SANDBOX. (defalias 'nix-compile #[(sandbox &rest command) "\302\303\304 #!\207" [sandbox command compile apply nix-shell-string] 5 (#$ . 1963) "Dsandbox: \nMcommand: "]) #@59 Run a COMMAND in the given SANDBOX and return the output. (defalias 'nix-sandbox/nix-shell #[(sandbox &rest command) "\302\303\304 #!\207" [sandbox command shell-command-to-string apply nix-shell-string] 5 (#$ . 2185)]) (defvar nix-exec-path-map (make-hash-table :test 'equal :size 4)) #@46 Return the `exec-path' of the given SANDBOX. (defalias 'nix-exec-path #[(sandbox) "\302 \"\206\303\304\305\306\307\310#!\311\" #\207" [sandbox nix-exec-path-map gethash puthash split-string s-trim nix-sandbox/nix-shell "printenv" "PATH" ":"] 8 (#$ . 2478)]) #@48 Search for an EXECUTABLE in the given SANDBOX. (defalias 'nix-executable-find #[(sandbox executable) "\303!\211\205 \304\n!)\207" [sandbox exec-path executable nix-exec-path executable-find] 3 (#$ . 2747)]) #@252 Search for a sandbox starting at PATH traversing upwards the directory tree. If the directory contains a `shell.nix' file, the path to this file is returned. Otherwise if the directory contains a `default.nix' file, the parent directory is returned. (defalias 'nix-find-sandbox #[(path) "\304!\205(\305\211\306\307\310\"\"\211\205\n\311P\n\203&\304 !\203& \202'\n+\207" [path map-nil sandbox-directory shell-nix file-exists-p #[(f x) "\205 !\207" [x f] 2] expand-file-name locate-dominating-file (lambda (dir) (seq-filter (lambda (candidate) (not (file-directory-p candidate))) (directory-files dir t ".*\\.nix$"))) "shell.nix"] 6 (#$ . 2964)]) #@82 Return the path of the sandbox that is closest to the current working directory. (defalias 'nix-current-sandbox #[nil "\301!\207" [default-directory nix-find-sandbox] 2 (#$ . 3631)]) #@45 Clear cached information for all sandboxes. (defalias 'nix-clear-caches #[nil "\302!\210\302 !\207" [nix-sandbox-rc-map nix-exec-path-map clrhash] 2 (#$ . 3821) nil]) (provide 'nix-sandbox)