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
ddeda0b6
Unverified
Commit
ddeda0b6
authored
6 years ago
by
Eelco Dolstra
Browse files
Options
Downloads
Plain Diff
Merge branch 'nix-upgrade-profile' of
https://github.com/LnL7/nix
parents
264e66f6
d85bb481
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/nix/upgrade-nix.cc
+23
-11
23 additions, 11 deletions
src/nix/upgrade-nix.cc
with
23 additions
and
11 deletions
src/nix/upgrade-nix.cc
+
23
−
11
View file @
ddeda0b6
#include
"command.hh"
#include
"common-args.hh"
#include
"store-api.hh"
#include
"download.hh"
#include
"eval.hh"
...
...
@@ -6,7 +7,7 @@
using
namespace
nix
;
struct
CmdUpgradeNix
:
StoreCommand
struct
CmdUpgradeNix
:
MixDryRun
,
StoreCommand
{
Path
profileDir
;
std
::
string
storePathsUrl
=
"https://github.com/NixOS/nixpkgs/raw/master/nixos/modules/installer/tools/nix-fallback-paths.nix"
;
...
...
@@ -68,21 +69,25 @@ struct CmdUpgradeNix : StoreCommand
{
Activity
act
(
*
logger
,
lvlInfo
,
actUnknown
,
fmt
(
"downloading '%s'..."
,
storePath
));
store
->
ensurePath
(
storePath
);
if
(
!
dryRun
)
store
->
ensurePath
(
storePath
);
}
{
Activity
act
(
*
logger
,
lvlInfo
,
actUnknown
,
fmt
(
"verifying that '%s' works..."
,
storePath
));
auto
program
=
storePath
+
"/bin/nix-env"
;
auto
s
=
runProgram
(
program
,
false
,
{
"--version"
});
if
(
s
.
find
(
"Nix"
)
==
std
::
string
::
npos
)
throw
Error
(
"could not verify that '%s' works"
,
program
);
if
(
!
dryRun
)
{
auto
program
=
storePath
+
"/bin/nix-env"
;
auto
s
=
runProgram
(
program
,
false
,
{
"--version"
});
if
(
s
.
find
(
"Nix"
)
==
std
::
string
::
npos
)
throw
Error
(
"could not verify that '%s' works"
,
program
);
}
}
{
Activity
act
(
*
logger
,
lvlInfo
,
actUnknown
,
fmt
(
"installing '%s' into profile '%s'..."
,
storePath
,
profileDir
));
runProgram
(
settings
.
nixBinDir
+
"/nix-env"
,
false
,
{
"--profile"
,
profileDir
,
"-i"
,
storePath
,
"--no-sandbox"
});
if
(
!
dryRun
)
runProgram
(
settings
.
nixBinDir
+
"/nix-env"
,
false
,
{
"--profile"
,
profileDir
,
"-i"
,
storePath
,
"--no-sandbox"
});
}
}
...
...
@@ -105,11 +110,18 @@ struct CmdUpgradeNix : StoreCommand
if
(
hasPrefix
(
where
,
"/run/current-system"
))
throw
Error
(
"Nix on NixOS must be upgraded via 'nixos-rebuild'"
);
Path
profileDir
;
Path
userEnv
;
Path
profileDir
=
dirOf
(
where
);
// Resolve profile to /nix/var/nix/profiles/<name> link.
while
(
baseNameOf
(
dirOf
(
canonPath
(
profileDir
)))
!=
"profiles"
)
profileDir
=
readLink
(
profileDir
);
printInfo
(
"found profile '%s'"
,
profileDir
);
Path
userEnv
=
canonPath
(
profileDir
,
true
);
if
(
baseNameOf
(
where
)
!=
"bin"
||
!
hasSuffix
(
userEnv
=
canonPath
(
profileDir
=
dirOf
(
where
),
true
)
,
"user-environment"
))
!
hasSuffix
(
userEnv
,
"user-environment"
))
throw
Error
(
"directory '%s' does not appear to be part of a Nix profile"
,
where
);
if
(
!
store
->
isValidPath
(
userEnv
))
...
...
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