Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Nix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nora Puchreiner
Nix
Commits
d93b3735
Unverified
Commit
d93b3735
authored
4 years ago
by
Eelco Dolstra
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #4036 from chreekat/b/prefetch-executable
nix-prefetch-url: Add --executable flag
parents
958bf571
5fe375a8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc/manual/src/command-ref/nix-prefetch-url.md
+3
-0
3 additions, 0 deletions
doc/manual/src/command-ref/nix-prefetch-url.md
src/nix-prefetch-url/nix-prefetch-url.cc
+9
-2
9 additions, 2 deletions
src/nix-prefetch-url/nix-prefetch-url.cc
with
12 additions
and
2 deletions
doc/manual/src/command-ref/nix-prefetch-url.md
+
3
−
0
View file @
d93b3735
...
@@ -51,6 +51,9 @@ Nix store is also printed.
...
@@ -51,6 +51,9 @@ Nix store is also printed.
result to the Nix store. The resulting hash can be used with
result to the Nix store. The resulting hash can be used with
functions such as Nixpkgs’s
`fetchzip`
or
`fetchFromGitHub`
.
functions such as Nixpkgs’s
`fetchzip`
or
`fetchFromGitHub`
.
-
`--executable`
Set the executable bit on the downloaded file.
-
`--name`
*name*
-
`--name`
*name*
Override the name of the file in the Nix store. By default, this is
Override the name of the file in the Nix store. By default, this is
`hash-basename`
, where
*basename*
is the last component of
*url*
.
`hash-basename`
, where
*basename*
is the last component of
*url*
.
...
...
This diff is collapsed.
Click to expand it.
src/nix-prefetch-url/nix-prefetch-url.cc
+
9
−
2
View file @
d93b3735
...
@@ -57,6 +57,7 @@ static int _main(int argc, char * * argv)
...
@@ -57,6 +57,7 @@ static int _main(int argc, char * * argv)
bool
fromExpr
=
false
;
bool
fromExpr
=
false
;
string
attrPath
;
string
attrPath
;
bool
unpack
=
false
;
bool
unpack
=
false
;
bool
executable
=
false
;
string
name
;
string
name
;
struct
MyArgs
:
LegacyArgs
,
MixEvalArgs
struct
MyArgs
:
LegacyArgs
,
MixEvalArgs
...
@@ -81,6 +82,8 @@ static int _main(int argc, char * * argv)
...
@@ -81,6 +82,8 @@ static int _main(int argc, char * * argv)
}
}
else
if
(
*
arg
==
"--unpack"
)
else
if
(
*
arg
==
"--unpack"
)
unpack
=
true
;
unpack
=
true
;
else
if
(
*
arg
==
"--executable"
)
executable
=
true
;
else
if
(
*
arg
==
"--name"
)
else
if
(
*
arg
==
"--name"
)
name
=
getArg
(
*
arg
,
arg
,
end
);
name
=
getArg
(
*
arg
,
arg
,
end
);
else
if
(
*
arg
!=
""
&&
arg
->
at
(
0
)
==
'-'
)
else
if
(
*
arg
!=
""
&&
arg
->
at
(
0
)
==
'-'
)
...
@@ -175,7 +178,11 @@ static int _main(int argc, char * * argv)
...
@@ -175,7 +178,11 @@ static int _main(int argc, char * * argv)
/* Download the file. */
/* Download the file. */
{
{
AutoCloseFD
fd
=
open
(
tmpFile
.
c_str
(),
O_WRONLY
|
O_CREAT
|
O_EXCL
,
0600
);
auto
mode
=
0600
;
if
(
executable
)
mode
=
0700
;
AutoCloseFD
fd
=
open
(
tmpFile
.
c_str
(),
O_WRONLY
|
O_CREAT
|
O_EXCL
,
mode
);
if
(
!
fd
)
throw
SysError
(
"creating temporary file '%s'"
,
tmpFile
);
if
(
!
fd
)
throw
SysError
(
"creating temporary file '%s'"
,
tmpFile
);
FdSink
sink
(
fd
.
get
());
FdSink
sink
(
fd
.
get
());
...
@@ -201,7 +208,7 @@ static int _main(int argc, char * * argv)
...
@@ -201,7 +208,7 @@ static int _main(int argc, char * * argv)
tmpFile
=
unpacked
;
tmpFile
=
unpacked
;
}
}
const
auto
method
=
unpack
?
FileIngestionMethod
::
Recursive
:
FileIngestionMethod
::
Flat
;
const
auto
method
=
unpack
||
executable
?
FileIngestionMethod
::
Recursive
:
FileIngestionMethod
::
Flat
;
auto
info
=
store
->
addToStoreSlow
(
name
,
tmpFile
,
method
,
ht
,
expectedHash
);
auto
info
=
store
->
addToStoreSlow
(
name
,
tmpFile
,
method
,
ht
,
expectedHash
);
storePath
=
info
.
path
;
storePath
=
info
.
path
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment