-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add option to jailbreak packages or not #6
Open
Shimuuar
wants to merge
4
commits into
SiriusCourses:master
Choose a base branch
from
Shimuuar:jailbreak
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+40
−16
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -93,13 +93,21 @@ data ConfigTests = ConfigTests | |||||
|
||||||
type instance RuleResult ConfigTests = Bool | ||||||
|
||||||
-- | Key to obtain jailbreak | ||||||
data ConfigJailbreak = ConfigJailbreak | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
deriving stock (Show, Eq, Generic) | ||||||
deriving anyclass (Hashable, Binary, FromJSON, NFData) | ||||||
|
||||||
type instance RuleResult ConfigJailbreak = Bool | ||||||
|
||||||
|
||||||
data Config = Config | ||||||
{ cfgRevision :: !String -- ^ Hackage revision | ||||||
, cfgGhcVersion :: !String -- ^ GHC version to pass to cabal2nix | ||||||
, cfgProfile :: !Bool -- ^ Whether to build profiling | ||||||
, cfgHaddock :: !Bool -- ^ Whether to build haddocks | ||||||
, cfgTests :: !Bool | ||||||
, cfgTests :: !Bool -- ^ Whether to enable tests | ||||||
, cfgJailbreak :: !Bool -- ^ Whether to apply jailbreak to package | ||||||
} | ||||||
deriving stock (Show, Eq, Generic) | ||||||
deriving anyclass (Hashable, Binary, NFData) | ||||||
|
@@ -108,16 +116,18 @@ instance FromJSON Config where | |||||
parseJSON = withObject "Config" $ \o -> do | ||||||
cfgRevision <- o .: "revision" | ||||||
cfgGhcVersion <- o .: "ghc_version" | ||||||
cfgProfile <- o .:? "profile" .!= False | ||||||
cfgHaddock <- o .:? "haddock" .!= False | ||||||
cfgTests <- o .:? "tests" .!= False | ||||||
cfgProfile <- o .:? "profile" .!= False | ||||||
cfgHaddock <- o .:? "haddock" .!= False | ||||||
cfgTests <- o .:? "tests" .!= False | ||||||
cfgJailbreak <- o .:? "jailbreak" .!= True | ||||||
pure Config{..} | ||||||
|
||||||
|
||||||
-- | Information about package. | ||||||
data Package = Package | ||||||
{ packageSource :: Source -- ^ Source location for package | ||||||
, packageParams :: [String] -- ^ Code fragments to pass to package | ||||||
{ packageSource :: Source -- ^ Source location for package | ||||||
, packageParams :: [String] -- ^ Code fragments to pass to package | ||||||
, packageJailbreak :: !Bool -- ^ Whether to apply jailbreak to package | ||||||
} | ||||||
deriving stock (Show, Eq, Generic) | ||||||
deriving anyclass (Hashable, Binary, NFData) | ||||||
|
@@ -140,10 +150,11 @@ data Git = Git | |||||
|
||||||
instance FromJSON Package where | ||||||
parseJSON v@String{} = do src <- parseJSON v | ||||||
pure $ Package src [] | ||||||
pure $ Package src [] True | ||||||
parseJSON v@(Object o) = do src <- (SourceCabal <$> o .: "hackage") <|> parseJSON v | ||||||
param <- o .:? "parameters" .!= [] | ||||||
pure $ Package src param | ||||||
jail <- o .:? "jailbreak" .!= True | ||||||
pure $ Package src param jail | ||||||
parseJSON _ = fail "Cannot parse package" | ||||||
|
||||||
instance FromJSON Source where | ||||||
|
@@ -193,11 +204,12 @@ main = do | |||||
case nm `Map.lookup` repo_set of | ||||||
Just s -> pure s | ||||||
Nothing -> error $ "No such repository: " ++ nm | ||||||
get_revision <- addOracle $ \ConfigRevisionKey -> pure $ cfgRevision config | ||||||
get_ghcver <- addOracle $ \ConfigGhcVersion -> pure $ cfgGhcVersion config | ||||||
get_profile <- addOracle $ \ConfigProfile -> pure $ cfgProfile config | ||||||
get_haddock <- addOracle $ \ConfigHaddock -> pure $ cfgHaddock config | ||||||
get_tests <- addOracle $ \ConfigTests -> pure $ cfgTests config | ||||||
get_revision <- addOracle $ \ConfigRevisionKey -> pure $ cfgRevision config | ||||||
get_ghcver <- addOracle $ \ConfigGhcVersion -> pure $ cfgGhcVersion config | ||||||
get_profile <- addOracle $ \ConfigProfile -> pure $ cfgProfile config | ||||||
get_haddock <- addOracle $ \ConfigHaddock -> pure $ cfgHaddock config | ||||||
get_tests <- addOracle $ \ConfigTests -> pure $ cfgTests config | ||||||
get_jailbreak <- addOracle $ \ConfigJailbreak -> pure $ cfgJailbreak config | ||||||
-- Phony targets | ||||||
phony "clean" $ do | ||||||
removeFilesAfter "nix/" ["pkgs/haskell/*.nix", "default.nix"] | ||||||
|
@@ -257,16 +269,23 @@ main = do | |||||
profile::String <- get_profile ConfigProfile <&> \case | ||||||
True -> "lib.enableLibraryProfiling" | ||||||
False -> "lib.disableLibraryProfiling" | ||||||
jailbreak::String <- get_jailbreak ConfigJailbreak <&> \case | ||||||
True -> "lib.doJailbreak" | ||||||
False -> "lib.dontJailbreak" | ||||||
liftIO $ writeFile overlay $ unlines $ concat | ||||||
[ [ "pkgs: prev:" | ||||||
, "let" | ||||||
, " lib = pkgs.haskell.lib;" | ||||||
, [fmt| adjust = drv: lib.doJailbreak ({profile} ({haddock} ({tests} drv)));|] | ||||||
, [fmt| adjust = drv: {jailbreak} ({profile} ({haddock} ({tests} drv)));|] | ||||||
, "in" | ||||||
, "{" | ||||||
] | ||||||
, [ [fmt| {nm} = adjust (prev.callPackage ./{packageNixName nm} {{ {concat $ fmap (++";") param} }});|] | ||||||
| (nm, Package{packageParams=param}) <- Map.toList pkgs_set | ||||||
, [ [fmt| {nm} = {fin};|] | ||||||
| (nm, Package{packageParams=param,packageJailbreak=jail}) <- Map.toList pkgs_set | ||||||
, let pkg,fin :: String | ||||||
pkg = [fmt|adjust (prev.callPackage ./{packageNixName nm} {{ {concat $ fmap (++";") param} }})|] | ||||||
fin | jail = [fmt|lib.doJailbreak ({pkg})|] | ||||||
| otherwise = pkg | ||||||
] | ||||||
, ["}"] | ||||||
] | ||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
97