packages feed

shellify 0.11.0.5 → 0.12.0.0

raw patch · 19 files changed

+452/−90 lines, 19 filesdep +parsec

Dependencies added: parsec

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # Changelog for Shellify +## 0.12.0+- Add --allow-local-pinned-registries-to-be-prioritized switch+- Prioiritise registries favouring those not pinned to local+ ## 0.11.0 - Drop the shellify executable in favour or nix-shellify 
shellify.cabal view
@@ -1,6 +1,6 @@ cabal-version:      3.0 name:               shellify-version:            0.11.0.5+version:            0.12.0.0  author: Daniel Rolls maintainer: daniel.rolls.27@googlemail.com@@ -57,6 +57,7 @@         extra >=1.7.13 && <1.9,         HStringTemplate >=0.8.8 && <0.9,         mtl >=2.2.2 && <2.4,+        parsec >=3.1.17.0 && <3.2,         shake >=0.19.7 && <0.20,         unordered-containers >=0.2.19.1 && <0.3 @@ -75,6 +76,8 @@     other-modules:         Paths_shellify,         TestHelpers+    autogen-modules:+        Paths_shellify     ghc-options: -threaded -rtsopts -with-rtsopts=-N     build-depends:         hspec >=2.9.7 && <2.12,
src/Constants.hs view
@@ -26,6 +26,12 @@     the versions of dependencies are kept for reproducibility and so that     shells are cached to load faster. +    --allow-local-pinned-registries-to-be-prioritized+    Pinned local repoisitory URLs are usually taken last when looking for URLs for+    generated flake.nix files. This is usually desired. If you do however want+    to see these pinned entries in the flake file as specified in your registry,+    then set this flag.+     --version     Show the version number |]
src/Options.hs view
@@ -29,6 +29,7 @@     packages :: Packages   , command :: Maybe Text   , generateFlake :: Bool+  , prioritiseLocalPinnedSystem :: Bool }  data OptionsParser = OptionsParser [Text] -- remainingOptions@@ -59,6 +60,7 @@         oldStyleOption opt = baseOption opt         newStyleOption "-p" = returnError "-p not supported with new style commands"         newStyleOption "--packages" = returnError "--packages not supported with new style commands"+        newStyleOption "--allow-local-pinned-registries-to-be-prioritized" = transformOptionsWith setPrioritiseLocalPinnedSystem         newStyleOption arg | isSwitch arg = baseOption arg                            | otherwise = transformOptionsWith $ appendPackages [arg]         baseOption :: Text -> [Text] -> OptionsParser@@ -82,6 +84,7 @@         appendPackages ps opts = opts{packages=ps ++ packages opts}         setCommand cmd opts = opts{command=Just cmd}         setFlakeGeneration opts = opts{generateFlake=True}+        setPrioritiseLocalPinnedSystem opts = opts {prioritiseLocalPinnedSystem=True}         returnError errorText remaining = OptionsParser remaining $ Left errorText  consumePackageArgs :: [Text] -> (Packages, [Text])@@ -99,7 +102,7 @@ isSwitch = isPrefixOf "-"  instance Default Options where-  def = Options [] Nothing False+  def = Options [] Nothing False False  instance Eq Options where   a == b =  isEqual command
src/TemplateGeneration.hs view
@@ -1,24 +1,23 @@ module TemplateGeneration (generateShellDotNixText, generateFlakeText, getRegistryDB) where -import Prelude hiding (lines)- import Constants import FlakeTemplate import Options import ShellifyTemplate +import Data.Bifunctor (bimap) import Data.Bool (bool)-import Data.List (find, sort)-import Data.List.Extra ((!?))-import Data.Maybe (catMaybes, fromMaybe)+import Data.List (find, sort, sortBy, sortOn)+import Data.Maybe (fromMaybe) import Data.Set (fromList, toList)-import Data.Text (isInfixOf, isPrefixOf, lines, pack, splitOn, Text())+import Data.Text (Text(), isInfixOf, isPrefixOf, pack, splitOn, unpack) import Development.Shake.Command (cmd, Exit(Exit), Stderr(Stderr), Stdout(Stdout)) import System.Exit (ExitCode (ExitSuccess))+import Text.ParserCombinators.Parsec (Parser, char, endBy, eof, many1, noneOf, parse, string, (<|>)) import Text.StringTemplate (newSTMP, render, setAttribute)  generateFlakeText :: Text -> Options -> Maybe Text-generateFlakeText db Options{packages=packages, generateFlake=shouldGenerateFlake} =+generateFlakeText db Options{packages=packages, generateFlake=shouldGenerateFlake, prioritiseLocalPinnedSystem=prioritiseLocalPinnedSystem} =   bool     Nothing     (Just $ render@@ -28,15 +27,15 @@           $ setAttribute "shell_args" shellArgs           $ newSTMP flakeTemplate)     shouldGenerateFlake-  where repos = uniq $ getPackageRepo <$> sort packages+  where repos = getPackageRepoWrapper packages         repoVars = getPackageRepoVarName <$> repos         repoInputs = repoInput <$> repos         repoInputLine repoName url = repoName <> ".url = \"" <> url <> "\";"         repoInput repoName = repoInputLine repoName .           either-            (error "Unexpected output from nix registry call: " <>)+            (error . ("Unexpected output from nix registry call: " <>))             (fromMaybe "PLEASE ENTER input here")-            . findFlakeRepoUrl db $ repoName+            . findFlakeRepoUrl prioritiseLocalPinnedSystem db $ repoName         pkgsVar = (<> "Pkgs")         pkgsVars = pkgsVar <$> repos         pkgsDecls = (\repo -> pkgsDecl (pkgsVar repo) repo) <$> repos@@ -52,9 +51,12 @@           command   $ newSTMP shellifyTemplate   where pkgs = generateBuildInput <$> sort packages-        parameters = uniq $ generateParameters <$> sort packages+        parameters = generateParametersWrapper packages         generateBuildInput input = (toImportVar . getPackageRepo) input <> "." <> getPackageName input +getPackageRepoWrapper :: [Package] -> [Text]+getPackageRepoWrapper = uniq . ("nixpkgs" :) . fmap getPackageRepo . sort+ getPackageRepo input | "#" `isInfixOf` input                         = head $ splitOn "#" input                      | otherwise@@ -73,6 +75,9 @@ getPackageRepoVarName "nixpkgs" = "pkgs" getPackageRepoVarName a = a +generateParametersWrapper :: [Package] -> [Text]+generateParametersWrapper = uniq . ("pkgs ? import <nixpkgs> {}" :) . fmap generateParameters . sort+ generateParameters :: Package -> Text generateParameters package | "#" `isInfixOf` package                            && not ("nixpkgs#" `isPrefixOf` package)@@ -90,23 +95,40 @@                       (Right $ pack out)                       (ex == ExitSuccess) -findFlakeRepoUrl :: Text -> Text -> Either Text (Maybe Text)-findFlakeRepoUrl haystack needle =-       fmap repoUrl . find ((needle ==) . repoName) . catMaybes <$> mapM getFlakeRepo (lines haystack)+findFlakeRepoUrl :: Bool -> Text -> Text -> Either String (Maybe Text)+findFlakeRepoUrl prioritiseLocalPinnedSystem haystack needle =+  bimap ((<>) "Error processing nix registry list output: " . show)+        (fmap repoUrl . find ((needle ==) . repoName)+                       . (if prioritiseLocalPinnedSystem then sortOn repoType else sortBy compareRepoEntries))+        $ parse parseRepos "" . unpack $ haystack +compareRepoEntries repoA repoB+  | repoHasLocalPinning repoA && not (repoHasLocalPinning repoB) = GT+  | repoHasLocalPinning repoB && not (repoHasLocalPinning repoA) = LT+  | otherwise = repoType repoA `compare` repoType repoB+  where repoHasLocalPinning = isPrefixOf "path:" . repoUrl++data RepoType = User | System | Global+                deriving (Eq, Ord)+ data FlakeRepo = FlakeRepo {     repoName :: Text   , repoUrl :: Text+  , repoType :: RepoType } -getFlakeRepo :: Text -> Either Text (Maybe FlakeRepo)-getFlakeRepo line = let expectedField = maybe (Left "unexepected nix registry command format")-                                              Right-                                        . (!?) (splitOn " " line)-                        urlField = expectedField 2-                        splitRepoField = splitOn ":" <$> expectedField 1-                        potentialFlakeName ["flake", b] = Just b-                        potentialFlakeName _ = Nothing-                        f x y = (`FlakeRepo` y) <$> potentialFlakeName x-                     in f <$> splitRepoField <*> urlField+parseRepos :: Parser [FlakeRepo]+parseRepos = do res <- endBy parseLine (char '\n')+                eof+                return res+  where parseLine = do repoType <- parseRepoType+                       char ' '+                       flakeName <- string "flake:" >> parseParam+                       char ' '+                       repoUrl <- parseParam+                       return $ FlakeRepo (pack flakeName) (pack repoUrl) repoType+        parseParam = many1 (noneOf " \n")+        parseRepoType = (string "global" >> return Global)+                    <|> (string "system" >> return System)+                    <|> (string "user" >> return User) 
test/Spec.hs view
@@ -1,4 +1,4 @@-import Test.Hspec (describe, hspec, it, shouldBe)+import Test.Hspec (describe, hspec, it, shouldBe, specify)  import Options import TestHelpers@@ -7,7 +7,8 @@ main = hspec $ do    describe "When passing option combinations" $ do-    it "should print a message saying no package is specified when no argument is supplied" $++    it "prints a message saying no package is specified when no argument is supplied" $       shellifyWithArgs ""         `shouldReturnSubstring`       "without any packages specified"@@ -17,12 +18,12 @@         `shouldReturnSubstring`       "without any packages specified" -    it "should show help text when requested" $ do+    it "shows help text when requested" $ do       shellifyWithArgs "-h"           `shouldReturnSubstring` "USAGE:"       shellifyWithArgs "--help"           `shouldReturnSubstring` "USAGE:"-    it "should show the version number when requested" $ do+    it "shows the version number when requested" $ do       shellifyWithArgs "--version"           `shouldReturnSubstring` "Shellify 0." @@ -34,88 +35,145 @@          `shouldBe`         Left "--packages not supported with new style commands" -    it "should allow a simple command to be specified with a package" $-      theOptions "-p python --command cowsay"-        `shouldBe`-      Right def{packages=["python"], command=Just "cowsay"}+    describe "When using the --command option" $ do -    it "should allow a simple command to be specified before a package" $-      theOptions "--run cowsay -p python"-        `shouldBe`-      Right def{packages=["python"], command=Just "cowsay"}+      it "produces a shell with a shell hook" $+          shellifyWithArgs "-p python -p cowsay --command cowsay"+            `shouldReturnShellTextDefinedBy`+          "two-build-inputs-and-command" -    it "should allow a simple command to be specified before and after a package" $-      theOptions "-p cowsay --command cowsay -p python"-        `shouldBe`-      Right def{packages=[ "cowsay", "python" ], command=Just "cowsay"}+      it "allows a command to be specified with a package" $+        theOptions "-p python --command cowsay"+          `shouldBe`+        Right def{packages=["python"], command=Just "cowsay"} -    it "Should fail if command has no argument" $ do-      shellifyWithArgs "--command -p python"-          `shouldReturnSubstring` "Argument missing to switch"-      shellifyWithArgs "--command"-          `shouldReturnSubstring` "Argument missing to switch"+      it "allows a command to be specified before a package" $+        theOptions "--run cowsay -p python"+          `shouldBe`+        Right def{packages=["python"], command=Just "cowsay"} -    it "should be able to specify one program to install after other arguments" $+      it "allows a command to be specified before and after a package" $+        theOptions "-p cowsay --command cowsay -p python"+          `shouldBe`+        Right def{packages=[ "cowsay", "python" ], command=Just "cowsay"}++      it "fails if command has no argument" $ do+        shellifyWithArgs "--command -p python"+            `shouldReturnSubstring` "Argument missing to switch"+        shellifyWithArgs "--command"+            `shouldReturnSubstring` "Argument missing to switch"++    it "supports specifying one program to install after other arguments" $       "foo -p python"         `shouldResultInPackages`       [ "python" ] -    it "should support multiple packages passed to -p" $+    it "supports multiple packages passed to -p" $       "-p python cowsay"         `shouldResultInPackages`       [ "cowsay", "python" ] -    it "should only accept packages up to the next switch" $+    it "only accepts packages up to the next switch" $       "-p python --arg x 2"         `shouldResultInPackages`       [ "python" ] -    it "should support multiple adjacent -p switches" $+    it "supports multiple adjacent -p switches" $       "-p python -p cowsay"         `shouldResultInPackages`       [ "python", "cowsay" ] -    it "should support separated -p switches" $+    it "supports separated -p switches" $       "-p cowsay --foo -p python"         `shouldResultInPackages`       [ "cowsay", "python" ] -    it "should support long switches" $+    it "supports long switches" $       "--packages cowsay"         `shouldResultInPackages`       [ "cowsay" ] -    it "should support new shell commands" $+    it "supports new shell commands" $       theOptions "shell nixpkgs#python nixpkgs#cowsay"         `shouldBe`       Right def{packages=[ "nixpkgs#python", "nixpkgs#cowsay" ], generateFlake=True} -  describe "when two buildInputs are required from two sources" $-    shellifyWithArgs "--with-flake shell foo#cowsay nixpkgs#python"-      `shouldReturnShellAndFlakeTextDefinedBy`-    "inputs-from-know-and-unknown-sources"+  describe "When dealing with multiple source repositories it should produce the correct output files for" $ do -  describe "when using 2 simple buildInputs from one source" $-    shellifyWithArgs "shell --with-flake python cowsay"-      `shouldReturnShellAndFlakeTextDefinedBy`-    "two-nixpkgs-inputs"+    specify "one buildInput required from an unknown source" $+      shellifyWithArgs "--with-flake shell foo#cowsay"+        `shouldReturnShellAndFlakeTextDefinedBy`+      "inputs-from-unknown-source" -  describe "when pulling from 2 different known sources" $-    shellifyWithArgs "shell nixpkgs#python blender-bin#blender_3_5"-      `shouldReturnShellAndFlakeTextDefinedBy`-    "inputs-from-different-registries"+    specify "two buildInputs required from two sources" $+      shellifyWithArgs "--with-flake shell foo#cowsay nixpkgs#python"+        `shouldReturnShellAndFlakeTextDefinedBy`+      "inputs-from-know-and-unknown-sources" -  describe "when working with 2 nixkgs buildInputs" $-      shellifyWithArgs "shell nixpkgs#python nixpkgs#cowsay"-        `shouldReturnShellTextDefinedBy`+    specify "2 buildInputs from one source" $+      shellifyWithArgs "shell --with-flake python cowsay"+        `shouldReturnShellAndFlakeTextDefinedBy`       "two-nixpkgs-inputs" -  describe "when working with multiple repos for known and unknown sources" $-      shellifyWithArgs "shell nixpkgs#python foo#cowsay"-        `shouldReturnShellTextDefinedBy`-      "multiple-repository-sources"+    specify "pulling from 2 different known sources" $+      shellifyWithArgs "shell nixpkgs#python blender-bin#blender_3_5"+        `shouldReturnShellAndFlakeTextDefinedBy`+      "inputs-from-different-registries" -  describe "when a command is specified" $-      shellifyWithArgs "-p python -p cowsay --command cowsay"-        `shouldReturnShellTextDefinedBy`-      "two-build-inputs-and-command"+    specify "2 nixpkgs buildInputs" $+        shellifyWithArgs "shell nixpkgs#python nixpkgs#cowsay"+          `shouldReturnShellTextDefinedBy`+        "two-nixpkgs-inputs"++    specify "multiple repos for known and unknown sources" $+        shellifyWithArgs "shell nixpkgs#python foo#cowsay"+          `shouldReturnShellTextDefinedBy`+        "multiple-repository-sources"++  describe "Where repository URLs need retrieving from the Nix Registry" $ do++    it "falls through to global where system is local and global is available" $+      whereALocalSystemAndFlakeGlobalNixpkgsExistsShellifyWithArgs "shell nixpkgs#cowsay"+        `shouldReturnShellAndFlakeTextDefinedBy`+      "cowsay-from-global-nixpkgs"++    it "prefers system to global where system is local and always-take-from-system-registry is specified" $+      whereALocalSystemAndFlakeGlobalNixpkgsExistsShellifyWithArgs "--allow-local-pinned-registries-to-be-prioritized shell nixpkgs#cowsay"+        `shouldReturnShellAndFlakeTextDefinedBy`+      "cowsay-from-local-nixpkgs"++    it "uses the local url where system has a local URL and no user or global repository is available" $+      whereALocalSystemNixpkgsExistsShellifyWithArgs "shell nixpkgs#cowsay"+        `shouldReturnShellAndFlakeTextDefinedBy`+      "cowsay-from-local-nixpkgs"++    it "uses the user registry when no system or global alternative exists" $+      whereAUserNixpkgsExistsShellifyWithArgs "shell nixpkgs#cowsay"+        `shouldReturnShellAndFlakeTextDefinedBy`+      "cowsay-from-user-nixpkgs"++    it "uses the system custom registry when a system and then global alternative are defined" $+      whereASystemAndGlobalCustomPkgsExistsShellifyWithArgs "shell custompkgs#cowsay"+        `shouldReturnShellAndFlakeTextDefinedBy`+      "cowsay-from-system-custompkgs"++    it "uses the system custom registry when a global and then system alternative are defined" $+      whereAGlobalAndSystemCustomPkgsExistsShellifyWithArgs "shell custompkgs#cowsay"+        `shouldReturnShellAndFlakeTextDefinedBy`+      "cowsay-from-system-custompkgs"++    it "uses the system nixpkgs when a system and then global alternative exist" $+      whereASystemAndGlobalNixpkgsExistsShellifyWithArgs "shell nixpkgs#cowsay"+        `shouldReturnShellAndFlakeTextDefinedBy`+      "cowsay-from-system-nixpkgs"++    it "uses the system nixpkgs when a global and then system alternative exist" $+      whereAGlobalAndSystemNixpkgsExistsShellifyWithArgs "shell nixpkgs#cowsay"+        `shouldReturnShellAndFlakeTextDefinedBy`+      "cowsay-from-system-nixpkgs"++    it "uses the global nixpkgs when no alternative exists" $+      whereOnlyAGlobalNixpkgsExistsShellifyWithArgs "shell nixpkgs#cowsay"+        `shouldReturnShellAndFlakeTextDefinedBy`+      "cowsay-from-global-nixpkgs"+
test/TestHelpers.hs view
@@ -1,11 +1,10 @@ module TestHelpers where -import Prelude hiding (last, putStrLn, readFile, reverse, tail, words)+import Prelude hiding (last, putStrLn, readFile, reverse, tail, unlines, words) import Data.Bool (bool)-import Data.Text (isInfixOf, last, reverse, tail, Text(), unpack, words)+import Data.Text (isInfixOf, last, reverse, tail, Text(), unpack, unlines, words) import Data.Text.IO (putStrLn, readFile) import Test.Hspec (Expectation(), expectationFailure, it, shouldBe, shouldContain)- import Options import Shellify import TemplateGeneration@@ -17,17 +16,107 @@       shellifyOutput  shellifyWithArgs :: Text -> Either Text [(Text, Text)]-shellifyWithArgs = parseOptionsAndCalculateExpectedFiles db "nix-shellify" . words+shellifyWithArgs = shellifyWithArgsWithDb realDbExample +realDbExample =+  [ "global flake:agda github:agda/agda"+  , "global flake:arion github:hercules-ci/arion"+  , "global flake:blender-bin github:edolstra/nix-warez?dir=blender"+  , "global flake:composable github:ComposableFi/composable"+  , "global flake:dreampkgs github:nix-community/dreampkgs"+  , "global flake:dwarffs github:edolstra/dwarffs"+  , "global flake:emacs-overlay github:nix-community/emacs-overlay"+  , "global flake:fenix github:nix-community/fenix"+  , "global flake:flake-parts github:hercules-ci/flake-parts"+  , "global flake:flake-utils github:numtide/flake-utils"+  , "global flake:gemini github:nix-community/flake-gemini"+  , "global flake:hercules-ci-effects github:hercules-ci/hercules-ci-effects"+  , "global flake:hercules-ci-agent github:hercules-ci/hercules-ci-agent"+  , "global flake:home-manager github:nix-community/home-manager"+  , "global flake:hydra github:NixOS/hydra"+  , "global flake:mach-nix github:DavHau/mach-nix"+  , "global flake:nimble github:nix-community/flake-nimble"+  , "global flake:nix github:NixOS/nix"+  , "global flake:nix-darwin github:LnL7/nix-darwin"+  , "global flake:nixops github:NixOS/nixops"+  , "global flake:nixos-hardware github:NixOS/nixos-hardware"+  , "global flake:nixos-homepage github:NixOS/nixos-homepage"+  , "global flake:nixos-search github:NixOS/nixos-search"+  , "global flake:nur github:nix-community/NUR"+  , "global flake:nixpkgs github:NixOS/nixpkgs/nixpkgs-unstable"+  , "global flake:templates github:NixOS/templates"+  , "global flake:patchelf github:NixOS/patchelf"+  , "global flake:poetry2nix github:nix-community/poetry2nix"+  , "global flake:nix-serve github:edolstra/nix-serve"+  , "global flake:nickel github:tweag/nickel"+  , "global flake:bundlers github:NixOS/bundlers"+  , "global flake:pridefetch github:SpyHoodle/pridefetch"+  , "global flake:systems github:nix-systems/default"+  , "global flake:helix github:helix-editor/helix"+  , "global flake:sops-nix github:Mic92/sops-nix"+  ]++shellifyWithArgsWithDb :: [Text] -> Text -> Either Text [(Text, Text)]+shellifyWithArgsWithDb customDb = parseOptionsAndCalculateExpectedFiles (unlines customDb) "nix-shellify" . words++whereAUserNixpkgsExistsShellifyWithArgs :: Text -> Either Text [(Text, Text)]+whereAUserNixpkgsExistsShellifyWithArgs = shellifyWithArgsWithDb+  [ "global flake:nixpkgs github:NixOS/nixpkgs/nixpkgs-global-registry"+  , "system flake:nixpkgs github:NixOS/nixpkgs/nixpkgs-system-registry"+  , "user flake:nixpkgs github:NixOS/nixpkgs/nixpkgs-user-registry"+  ]++whereASystemAndGlobalCustomPkgsExistsShellifyWithArgs :: Text -> Either Text [(Text, Text)]+whereASystemAndGlobalCustomPkgsExistsShellifyWithArgs = shellifyWithArgsWithDb+  [ "global flake:custompkgs github:NixOS/custompkgs/custompkgs-global-registry"+  , "system flake:custompkgs github:NixOS/custompkgs/custompkgs-system-registry"+  , "global flake:nixpkgs github:NixOS/nixpkgs/nixpkgs-unstable"+  ]++whereAGlobalAndSystemCustomPkgsExistsShellifyWithArgs :: Text -> Either Text [(Text, Text)]+whereAGlobalAndSystemCustomPkgsExistsShellifyWithArgs = shellifyWithArgsWithDb+  [ "system flake:custompkgs github:NixOS/custompkgs/custompkgs-system-registry"+  , "global flake:custompkgs github:NixOS/custompkgs/custompkgs-global-registry"+  , "global flake:nixpkgs github:NixOS/nixpkgs/nixpkgs-unstable"+  ]++whereASystemAndGlobalNixpkgsExistsShellifyWithArgs :: Text -> Either Text [(Text, Text)]+whereASystemAndGlobalNixpkgsExistsShellifyWithArgs = shellifyWithArgsWithDb+  [ "system flake:nixpkgs github:NixOS/nixpkgs/nixpkgs-system-registry"+  , "global flake:nixpkgs github:NixOS/nixpkgs/nixpkgs-global-registry"+  ]++whereAGlobalAndSystemNixpkgsExistsShellifyWithArgs :: Text -> Either Text [(Text, Text)]+whereAGlobalAndSystemNixpkgsExistsShellifyWithArgs = shellifyWithArgsWithDb+  [ "global flake:nixpkgs github:NixOS/nixpkgs/nixpkgs-global-registry"+  , "system flake:nixpkgs github:NixOS/nixpkgs/nixpkgs-system-registry"+  ]++whereOnlyAGlobalNixpkgsExistsShellifyWithArgs :: Text -> Either Text [(Text, Text)]+whereOnlyAGlobalNixpkgsExistsShellifyWithArgs = shellifyWithArgsWithDb+  [ "global flake:nixpkgs github:NixOS/nixpkgs/nixpkgs-global-registry"+  ]++whereALocalSystemAndFlakeGlobalNixpkgsExistsShellifyWithArgs :: Text -> Either Text [(Text, Text)]+whereALocalSystemAndFlakeGlobalNixpkgsExistsShellifyWithArgs = shellifyWithArgsWithDb+  [ "system flake:nixpkgs path:/local/nixpkgs/path"+  , "global flake:nixpkgs github:NixOS/nixpkgs/nixpkgs-global-registry"+  ]++whereALocalSystemNixpkgsExistsShellifyWithArgs :: Text -> Either Text [(Text, Text)]+whereALocalSystemNixpkgsExistsShellifyWithArgs = shellifyWithArgsWithDb+  [ "system flake:nixpkgs path:/local/nixpkgs/path"+  , "global flake:templates github:NixOS/templates"+  ]++shouldReturnShellAndFlakeTextDefinedBy :: Either Text [(Text, Text)] -> FilePath -> Expectation shouldReturnShellAndFlakeTextDefinedBy result expectedOutput =-     it "should produce the expected shell.nix and flake.nix" $-       do expShell <- readNixTemplate (shellFile expectedOutput)-          expFlake <- readNixTemplate (flakeFile expectedOutput)-          result `shouldBe`-              Right [("shell.nix", expShell),("flake.nix", expFlake)]+   do expShell <- readNixTemplate (shellFile expectedOutput)+      expFlake <- readNixTemplate (flakeFile expectedOutput)+      result `shouldBe`+          Right [("shell.nix", expShell),("flake.nix", expFlake)]  shouldReturnShellTextDefinedBy result expectedOutput =-     it "should produce the expected shell.nix" $        do expShell <- readNixTemplate (shellFile expectedOutput)           either             (const $ expectationFailure "Expected Right but got Left")@@ -36,14 +125,14 @@                      fileName `shouldBe` "shell.nix")             result -theOptions = options "nix-shellify" . words- shouldResultInPackages :: Text -> [Text] -> Expectation shouldResultInPackages parameters packages =      theOptions parameters        `shouldBe`      Right def{packages=packages} +theOptions = options "nix-shellify" . words+ instance Show Options  readNixTemplate :: FilePath -> IO Text@@ -56,4 +145,3 @@ flakeFile = (<> "-flake.nix") shellFile = (<> "-shell.nix") -db = "global flake:agda github:agda/agda\nglobal flake:arion github:hercules-ci/arion\nglobal flake:blender-bin github:edolstra/nix-warez?dir=blender\nglobal flake:composable github:ComposableFi/composable\nglobal flake:dreampkgs github:nix-community/dreampkgs\nglobal flake:dwarffs github:edolstra/dwarffs\nglobal flake:emacs-overlay github:nix-community/emacs-overlay\nglobal flake:fenix github:nix-community/fenix\nglobal flake:flake-parts github:hercules-ci/flake-parts\nglobal flake:flake-utils github:numtide/flake-utils\nglobal flake:gemini github:nix-community/flake-gemini\nglobal flake:hercules-ci-effects github:hercules-ci/hercules-ci-effects\nglobal flake:hercules-ci-agent github:hercules-ci/hercules-ci-agent\nglobal flake:home-manager github:nix-community/home-manager\nglobal flake:hydra github:NixOS/hydra\nglobal flake:mach-nix github:DavHau/mach-nix\nglobal flake:nimble github:nix-community/flake-nimble\nglobal flake:nix github:NixOS/nix\nglobal flake:nix-darwin github:LnL7/nix-darwin\nglobal flake:nixops github:NixOS/nixops\nglobal flake:nixos-hardware github:NixOS/nixos-hardware\nglobal flake:nixos-homepage github:NixOS/nixos-homepage\nglobal flake:nixos-search github:NixOS/nixos-search\nglobal flake:nur github:nix-community/NUR\nglobal flake:nixpkgs github:NixOS/nixpkgs/nixpkgs-unstable\nglobal flake:templates github:NixOS/templates\nglobal flake:patchelf github:NixOS/patchelf\nglobal flake:poetry2nix github:nix-community/poetry2nix\nglobal flake:nix-serve github:edolstra/nix-serve\nglobal flake:nickel github:tweag/nickel\nglobal flake:bundlers github:NixOS/bundlers\nglobal flake:pridefetch github:SpyHoodle/pridefetch\nglobal flake:systems github:nix-systems/default\nglobal flake:helix github:helix-editor/helix\nglobal flake:sops-nix github:Mic92/sops-nix\n" :: Text
+ test/outputs/cowsay-from-global-nixpkgs-flake.nix view
@@ -0,0 +1,20 @@+{+  description = "my project description";++  inputs = {++    flake-utils.url = "github:numtide/flake-utils";+    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-global-registry";++  };++  outputs = { self, nixpkgs, flake-utils }:+    flake-utils.lib.eachDefaultSystem+      (system:+        let nixpkgsPkgs = if builtins.hasAttr "packages" nixpkgs then nixpkgs.packages.${system} else ( if builtins.hasAttr "legacyPackages" nixpkgs then nixpkgs.legacyPackages.${system} else nixpkgs);+        in+        {+          devShells.default = import ./shell.nix { pkgs=nixpkgsPkgs; };+        }+      );+}
+ test/outputs/cowsay-from-global-nixpkgs-shell.nix view
@@ -0,0 +1,9 @@+{ pkgs ? import <nixpkgs> {} }:++pkgs.mkShell {++  buildInputs = [+    pkgs.cowsay+  ];++}
+ test/outputs/cowsay-from-local-nixpkgs-flake.nix view
@@ -0,0 +1,20 @@+{+  description = "my project description";++  inputs = {++    flake-utils.url = "github:numtide/flake-utils";+    nixpkgs.url = "path:/local/nixpkgs/path";++  };++  outputs = { self, nixpkgs, flake-utils }:+    flake-utils.lib.eachDefaultSystem+      (system:+        let nixpkgsPkgs = if builtins.hasAttr "packages" nixpkgs then nixpkgs.packages.${system} else ( if builtins.hasAttr "legacyPackages" nixpkgs then nixpkgs.legacyPackages.${system} else nixpkgs);+        in+        {+          devShells.default = import ./shell.nix { pkgs=nixpkgsPkgs; };+        }+      );+}
+ test/outputs/cowsay-from-local-nixpkgs-shell.nix view
@@ -0,0 +1,9 @@+{ pkgs ? import <nixpkgs> {} }:++pkgs.mkShell {++  buildInputs = [+    pkgs.cowsay+  ];++}
+ test/outputs/cowsay-from-system-custompkgs-flake.nix view
@@ -0,0 +1,22 @@+{+  description = "my project description";++  inputs = {++    flake-utils.url = "github:numtide/flake-utils";+    custompkgs.url = "github:NixOS/custompkgs/custompkgs-system-registry";+    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";++  };++  outputs = { self, custompkgs, nixpkgs, flake-utils }:+    flake-utils.lib.eachDefaultSystem+      (system:+        let custompkgsPkgs = if builtins.hasAttr "packages" custompkgs then custompkgs.packages.${system} else ( if builtins.hasAttr "legacyPackages" custompkgs then custompkgs.legacyPackages.${system} else custompkgs);+            nixpkgsPkgs = if builtins.hasAttr "packages" nixpkgs then nixpkgs.packages.${system} else ( if builtins.hasAttr "legacyPackages" nixpkgs then nixpkgs.legacyPackages.${system} else nixpkgs);+        in+        {+          devShells.default = import ./shell.nix { custompkgs=custompkgsPkgs; pkgs=nixpkgsPkgs; };+        }+      );+}
+ test/outputs/cowsay-from-system-custompkgs-shell.nix view
@@ -0,0 +1,9 @@+{ custompkgs, pkgs ? import <nixpkgs> {} }:++pkgs.mkShell {++  buildInputs = [+    custompkgs.cowsay+  ];++}
+ test/outputs/cowsay-from-system-nixpkgs-flake.nix view
@@ -0,0 +1,20 @@+{+  description = "my project description";++  inputs = {++    flake-utils.url = "github:numtide/flake-utils";+    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-system-registry";++  };++  outputs = { self, nixpkgs, flake-utils }:+    flake-utils.lib.eachDefaultSystem+      (system:+        let nixpkgsPkgs = if builtins.hasAttr "packages" nixpkgs then nixpkgs.packages.${system} else ( if builtins.hasAttr "legacyPackages" nixpkgs then nixpkgs.legacyPackages.${system} else nixpkgs);+        in+        {+          devShells.default = import ./shell.nix { pkgs=nixpkgsPkgs; };+        }+      );+}
+ test/outputs/cowsay-from-system-nixpkgs-shell.nix view
@@ -0,0 +1,9 @@+{ pkgs ? import <nixpkgs> {} }:++pkgs.mkShell {++  buildInputs = [+    pkgs.cowsay+  ];++}
+ test/outputs/cowsay-from-user-nixpkgs-flake.nix view
@@ -0,0 +1,20 @@+{+  description = "my project description";++  inputs = {++    flake-utils.url = "github:numtide/flake-utils";+    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-user-registry";++  };++  outputs = { self, nixpkgs, flake-utils }:+    flake-utils.lib.eachDefaultSystem+      (system:+        let nixpkgsPkgs = if builtins.hasAttr "packages" nixpkgs then nixpkgs.packages.${system} else ( if builtins.hasAttr "legacyPackages" nixpkgs then nixpkgs.legacyPackages.${system} else nixpkgs);+        in+        {+          devShells.default = import ./shell.nix { pkgs=nixpkgsPkgs; };+        }+      );+}
+ test/outputs/cowsay-from-user-nixpkgs-shell.nix view
@@ -0,0 +1,9 @@+{ pkgs ? import <nixpkgs> {} }:++pkgs.mkShell {++  buildInputs = [+    pkgs.cowsay+  ];++}
+ test/outputs/inputs-from-unknown-source-flake.nix view
@@ -0,0 +1,22 @@+{+  description = "my project description";++  inputs = {++    flake-utils.url = "github:numtide/flake-utils";+    foo.url = "PLEASE ENTER input here";+    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";++  };++  outputs = { self, foo, nixpkgs, flake-utils }:+    flake-utils.lib.eachDefaultSystem+      (system:+        let fooPkgs = if builtins.hasAttr "packages" foo then foo.packages.${system} else ( if builtins.hasAttr "legacyPackages" foo then foo.legacyPackages.${system} else foo);+            nixpkgsPkgs = if builtins.hasAttr "packages" nixpkgs then nixpkgs.packages.${system} else ( if builtins.hasAttr "legacyPackages" nixpkgs then nixpkgs.legacyPackages.${system} else nixpkgs);+        in+        {+          devShells.default = import ./shell.nix { foo=fooPkgs; pkgs=nixpkgsPkgs; };+        }+      );+}
+ test/outputs/inputs-from-unknown-source-shell.nix view
@@ -0,0 +1,9 @@+{ foo, pkgs ? import <nixpkgs> {} }:++pkgs.mkShell {++  buildInputs = [+    foo.cowsay+  ];++}