on master help sign in
Merge pull request #301 from obsidiansystems/nix-cmd-add-expr-support

Support expr in nix-* commands

commit5dc10342dc4b47cdf4896a5c351189d51d092626 authorLuigy Leon <luichi.19@gmail.com> dateMon 5 Nov 2018, 17:02 (8 years ago) parentc7d23eaca4165c
3 files changed+10−1
lib/command/src/Obelisk/Command/Deploy.hs+1 lib/command/src/Obelisk/Command/Nix.hs+7−1 lib/command/src/Obelisk/Command/Thunk.hs+2
lib/command/src/Obelisk/Command/Deploy.hs+1
@@ -101,6 +101,7 @@ deployPush deployPath getNixBuilders = do
101101 & nixCmdConfig_target .~Target
102102 { _target_path = Just srcPath
103103 , _target_attr = Just "server.system"
104+ , _target_expr = Nothing
104105 }
105106 & nixBuildConfig_outLink .~ OutLink_None
106107 & nixCmdConfig_args .~
lib/command/src/Obelisk/Command/Nix.hs+7−1
@@ -45,6 +45,7 @@ import Obelisk.CliApp
4545data Target = Target
4646 { _target_path :: Maybe FilePath
4747 , _target_attr :: Maybe String
48+ , _target_expr :: Maybe String
4849 }
4950makeClassy ''Target
5051
@@ -52,6 +53,7 @@ instance Default Target where
5253 def = Target
5354 { _target_path = Just "."
5455 , _target_attr = Nothing
56+ , _target_expr = Nothing
5557 }
5658
5759data Arg
@@ -84,13 +86,17 @@ instance Default NixCommonConfig where
8486 def = NixCommonConfig def mempty mempty
8587
8688runNixCommonConfig :: NixCommonConfig -> [FilePath]
87−runNixCommonConfig cfg = mconcat [maybeToList path, attrArg, args, buildersArg]
89+runNixCommonConfig cfg = mconcat [maybeToList path, attrArg, exprArg, args, buildersArg]
8890 where
8991 path = _target_path $ _nixCmdConfig_target cfg
9092 attr = _target_attr $ _nixCmdConfig_target cfg
93+ expr = _target_expr $ _nixCmdConfig_target cfg
9194 attrArg = case attr of
9295 Nothing -> []
9396 Just a -> ["-A", a]
97+ exprArg = case expr of
98+ Nothing -> []
99+ Just a -> ["-E", a]
94100 args = cliFromArgs $ _nixCmdConfig_args cfg
95101 buildersArg = case _nixCmdConfig_builders cfg of
96102 [] -> []
lib/command/src/Obelisk/Command/Thunk.hs+2
@@ -507,6 +507,7 @@ nixBuildThunkAttrWithCache thunkDir attr = do
507507 Lens.& nixCmdConfig_target Lens..~ Target
508508 { _target_path = Just thunkDir
509509 , _target_attr = Just attr
510+ , _target_expr = Nothing
510511 }
511512 return cachePath
512513
@@ -528,6 +529,7 @@ nixBuildAttrWithCache exprPath attr = do
528529 Lens.& nixCmdConfig_target Lens..~ Target
529530 { _target_path = Just exprPath
530531 , _target_attr = Just attr
532+ , _target_expr = Nothing
531533 }
532534
533535-- | Safely update thunk using a custom action